bbfu has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to use images in association with Win32::GUI::TreeView but I'm having some problems. I can get simple bitmaps to show up, but I'd like to use partially transparent bitmaps (ie bitmaps with associated bitmap masks), or (ideally) icon images in the TreeView. From what I've read in the docs, the following code is correct, but it doesn't work. Hopefully some wise monk can help me out. :)
Of course, the problem may be in the bitmap or icon files I'm using, so they're available at the following URLs:
FolderOpen.bmp
FolderOpenMask.bmp
FolderOpen.ico
#!perl/bin/perl use warnings; use strict; use Win32::GUI; my $main = Win32::GUI::Window->new( -name => 'Main', -width => 300, -height => 250, ); my $il = Win32::GUI::ImageList->new(16, 16, 32, 1, 5); # This shows the image, but it's not masked $il->Add('FolderOpen.bmp', 'FolderOpenMask.bmp'); # As does this #$il->AddBitmap( # Win32::GUI::Bitmap->new('FolderOpen.bmp', 0), # Win32::GUI::Bitmap->new('FolderOpenMask.bmp', 0), #); # And icon files don't work at all #$il->AddBitmap(Win32::GUI::Bitmap->new('FolderOpen.ico', 1)); my $tv = $main->AddTreeView( -name => 'TreeView', -width => 280, -height => 200, -top => 10, -left => 5, -buttons => 1, -rootlines => 1, -imagelist => $il, ); # Also, this doesn't seem to work, for some reason. # The ImageList has to be passed when constructing the TreeView. # Why? #$tv->SetImageList($il, 24); my $root = $tv->InsertItem( -text => 'Foo', -indent => 1, -image => 0, ); $tv->InsertItem( -text => 'Bar', -indent => 1, -image => 0, ); $tv->InsertItem( -text => 'Baz', -indent => 1, -image => 0, -parent => $root, ); $main->Show(1); Win32::GUI::Dialog(); sub Main_Terminate { return -1; }
bbfu
Black flowers blossom
Fearless on my breath
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Win32::GUI::TreeView and bitmap masks
by knexus (Hermit) on Sep 09, 2003 at 09:38 UTC | |
by bbfu (Curate) on Sep 09, 2003 at 12:25 UTC | |
by knexus (Hermit) on Sep 09, 2003 at 16:22 UTC | |
by bbfu (Curate) on Sep 10, 2003 at 02:53 UTC | |
by knexus (Hermit) on Sep 10, 2003 at 15:44 UTC | |
| |
by Anonymous Monk on May 09, 2011 at 06:54 UTC | |
| |
by bbfu (Curate) on Sep 09, 2003 at 17:02 UTC | |
by knexus (Hermit) on Sep 09, 2003 at 17:47 UTC |