I’ve been experimenting with toolbars recently and hit a snag. I needed some simple icons, so I extracted a few from Shell32.dll and imported them using BitmapInline. The problem is that some of them look really ugly and I’ve been banging my head for days trying to figure out exactly what the problem is. Thanks to some patient listening (off-list) by Jez White, I’ve narrowed my problem down to this:

 

 

Here is an example. Does anybody have any clues why this isn’t working correctly?

 

 

 

 

#!perl -w

 

use strict;

use warnings;

 

use Win32::GUI;

use Win32::GUI::BitmapInline ();

 

sub ILC_COLOR24()       {24};

sub ILC_MASK()                            {1};

 

my $mw = Win32::GUI::Window->new(

            -title      => "Icons",

            -size     => [120,180],

            -pos      => [200,200],

);

 

my $hIcon = CreateIcon();

 

$mw->AddLabel(

            -background      => 0xFFFFFF,

            -icon                 => $hIcon,

            -pos                  => [ 20, 20 ],

);

 

my $il = Win32::GUI::ImageList->new(16, 16, ILC_COLOR24|ILC_MASK, 1, 1);

$il->AddIcon($hIcon);

 

$mw->AddTreeView(

            -name               => "tv",

            -size                 => [ 100, 100 ],

            -pos                  => [ 0, 50 ],

            -buttons            => 1,

            -rootlines           => 1,

            -imagelist          => $il,

);

           

$mw->tv->InsertItem(-image => 0);

 

$mw->Show();

Win32::GUI::Dialog();

 

sub CreateIcon {

newIcon Win32::GUI::BitmapInline( q(

AAABAAEAEBAAAAEAAABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAQAQAAAAAAAAAAAAAAAAA

AAAAAAAAAAABAAAACQAAABMAAAAYAAAAGAAAABcAAAATAAAACwAAAAMAAAAAAAAAAAAAAAAAAAAA

AAAAAAAAAAAAAAAAAAAACwAAAC8AAABTAAAAXwAAAF8AAABeAAAAVgAAAEUAAAAtAAAAHAAAABsA

AAAhAAAAIwAAACIAAAAcAAAAD2YgAjeKLQyvfCsQzIMvG9ODLxvTZiIIzT0TAboAAACZAAAAggAA

AGgAAABnAAAAcwAAAHcAAAB2AAAAZwAAAD23PQ/F3VIz//ljUP/9cFv/82xS/9JuQf/4ZVH/zEop

+y0yB9cSVxLbIXkh6i2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