Can you post this on the sourceforge tracker as a suggestion if you haven't 
already? It's much more useful to put suggestions and bug reports there since 
otherwise they just lie around on the list and nobody can verify if they've 
been seen to or not :)
 
Steve

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Jez White
Sent: 14 January 2004 12:58
To: Win32-GUI
Subject: [perl-win32-gui-users] Button control. Is this a bug?


Hi,
 
A common newbie problem is creating a button with a bitmap. Typically you would 
start by creating a button and then use the SetImage method to associate the 
image to the button. When you run the program, nothing happens. After reading 
the list, and looking at examples you realise you have to use the -bitmap 
option when you create the button - problem solved. Shouldn't you be able to 
create an 'empty' button and then add a bitmap to it later? It seems the 
"state" of the button is fixed when it is created (text or bitmap) and this 
cannot be changed during runtime. It this correct behaviour? 
 
Below is an example, with comments showing this behaviour. It uses  
Win32::GUI::BitmapInline to encode the bitmaps, so you can run the example with 
no alteration.
 
cheers,
 
jez.
 
=========================
 
use strict;
use Win32::GUI;
use Win32::GUI::BitmapInline ();
 
my $BMP_UNKFOLDER;
my $BMP_DLL;
 
InitBitmaps();
 
my $win = new Win32::GUI::Window(
              -name   => 'topwin',
              -title => 'Button Test',
              -width  => 300,
              -height => 200,
              -pos => [125,75],
       -maximizebox => "0",
       -minimizebox => "0",
       -resizable => "0"
);
 
my $but = $win->AddButton(
          -cancel  => '0',
          -width   => '20',
          -top     => '20',
          -name    => 'bitmapbutton',
          -height  => '20',
          -left    => '20',
          -visible => '1',
          -default => '0',
          #if you uncomment the line below, an image is created, and you can 
then use SetImage
          #-bitmap  => $BMP_UNKFOLDER,
          -ok      => '0');
 
my $switch = $win->AddButton(
          -cancel  => '0',
          -width   => '60',
          -top     => '20',
          -name    => 'add',
          -height  => '20',
          -left    => '50',
          -visible => '1',
          -default => '0',
          -text  => 'Add Bitmap',
          -ok      => '0');
          
$win->Show();
 
Win32::GUI::Dialog();
 
sub topwin_Terminate {
        return -1;
}
 
sub add_Click {
  $but->SetImage($BMP_DLL);
}
 


sub InitBitmaps {
 
$BMP_UNKFOLDER = new Win32::GUI::BitmapInline( q(
Qk32AAAAAAAAAHYAAAAoAAAAEAAAABAAAAABAAQAAAAAAIAAAAAAAAAAAAAAABAAAAAQAAAAAAAA
AACcnABjzs4A9/f3AJzO/wCc//8Azv//AP///wD///8A////AP///wD///8A////AP///wD///8A
////AHd3d3d3d3d3d3d3d3d3d3dwAAAAAAAABxIiIiIiIiIHFkVFAEVEQgcWVVQAVFRCBxZVVVVF
RUIHFlVVAFRUUgcWVVUAVUVCBxZVVVAEVFIHFlUAVQBVQgcWZgBmAGZSBxIiIAABERF3cTZlUQd3
d3d3EREQd3d3d3d3d3d3d3d3
) );
 
$BMP_DLL = new Win32::GUI::BitmapInline( q(
Qk32AAAAAAAAAHYAAAAoAAAAEAAAABAAAAABAAQAAAAAAIAAAAAAAAAAAAAAABAAAAAQAAAAAAAA
AAAAgAAAgAAAAICAAIAAAACAAIAAgIAAAMDAwACAgIAAAAD/AAD/AAAA//8A/wAAAP8A/wD//wAA
////APAAAAAAAAD/+Hd3d3d3cP/4//////9w//j//////3D/+P//8A//cP/4//8HcP9w//j/+PCI
D3D/+P8HD4D/cP/487CID/9w//j/CzD//3D/+P8zD///cP/4//////9w//j/////AAD/+P////9/
j//4/////3j///iIiIiIj///
) );
 
}
 
 
 
 
 
 
 
 
 

Reply via email to