Hello,
I have a problem in that I am trying to build a window inside a package.
However, when I build a button inside the package, the bitmap does not
display.

For instance, I have this simple program:

use strict;
use warnings;
use Win32::GUI();
use Win32::GUI::Constants qw(BS_BITMAP);

my $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";
 
$mw->AddButton(
        -name      => "Up_Arrow",
        -left      => 5,
        -top       => 40,
        -width     => 25,
        -height    => 25,
        -pushstyle => BS_BITMAP,
        -visible   => 1,
        -onClick   => sub {print "UP\n";},
       );
 
$mw->Up_Arrow->SetImage($IMG1);
 
$mw->AddButton(
        -name      => "Down_Arrow",
        -left      => 5,
        -top       => 70,
        -width     => 25,
        -height    => 25,
        -pushstyle => BS_BITMAP,
        -visible   => 1,
        -onClick   => sub {print "DOWN\n";},
       );

$mw->Down_Arrow->SetImage($IMG2);

$mw->Show();
Win32::GUI::Dialog();
$mw->Hide();
exit(0);

The arrow images show up on the buttons in this case.
However, if I make a package as below (in a file called Testing.pm):

package Testing;

use strict;
use warnings;
use Win32::GUI();
use Win32::GUI::Constants qw(BS_BITMAP);


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
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/

Reply via email to