From: Ken S. <kl...@ps...> - 2011-03-30 11:07:53
|
Thanks Jeremy. Yes it was a simple problem, but I didn't see it. Ken From: Jeremy White [mailto:jez...@ho...] Sent: Tuesday, March 29, 2011 2:57 PM To: kl...@ps...; per...@li... Subject: RE: [perl-win32-gui-users] Button Bitmap inconsistency Quick reply, it could be a simple scoping problem: > package Testing; > > use strict; > use warnings; > use Win32::GUI(); > use Win32::GUI::Constants qw(BS_BITMAP); move the images here - that way the objects don't get destroyed when they go out of scope. my $IMG1 = new Win32::GUI::Bitmap("D:/WIN32GUI/up.bmp") or die "$^E\n"; my $IMG2 = new Win32::GUI::Bitmap("D:/WIN32GUI/down.bmp") or die "$^E\n"; > > > sub new { > my $proto = shift; > my $buttonCB = shift; > my $class = ref($proto) || $proto; > my $self = {}; > > $self->{mw} = Win32::GUI::Window->new(-title => "TEST", > -pos => [100,100], > -size => [200,200], > ); > > my $IMG1 = new Win32::GUI::Bitmap("D:/WIN32GUI/up.bmp") > or die "$^E\n"; > > my $IMG2 = new Win32::GUI::Bitmap("D:/WIN32GUI/down.bmp") > or die "$^E\n"; > > $self->{mw}->AddButton( > -name => "Up_Arrow", > -left => 5, > -top => 40, > -width => 25, > -height => 25, > -pushstyle => BS_BITMAP, > -visible => 1, > -onClick => sub {print "UP\n";}, > ); > > $self->{mw}->Up_Arrow->SetImage($IMG1); > > $self->{mw}->AddButton( > -name => "Down_Arrow", > -left => 5, > -top => 70, > -width => 25, > -height => 25, > -pushstyle => BS_BITMAP, > -visible => 1, > -onClick => sub {print "DOWN\n";}, > ); > > $self->{mw}->Down_Arrow->SetImage($IMG2); > > bless ($self, $class); > return $self; > } > > sub getMW > { > my $self = shift; > return $self->{mw}; > } > > 1 > > And use this package as follows: > > use strict; > use warnings; > use Win32::GUI(); > use Testing; > > > my $testing = Testing->new(); > my $mw = $testing->getMW(); > $mw->Show(); > Win32::GUI::Dialog(); > $mw->Hide(); > exit(0); > > The buttons are blank. Does anybody have any idea why this happens? > Or does it happen for others? > Of course the image file names would have to be changed for testing. > > Thanks, > Ken Slater > > > > > ---------------------------------------------------------------------------- -- > Enable your software for Intel(R) Active Management Technology to meet the > growing manageability and security demands of your customers. Businesses > are taking advantage of Intel(R) vPro (TM) technology - will your software > be a part of the solution? Download the Intel(R) Manageability Checker > today! http://p.sf.net/sfu/intel-dev2devmar > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ |