Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Win32::GUI Bitmaps on buttons?

by HaB (Sexton)
on Nov 21, 2000 at 19:22 UTC ( #42700=perlquestion: print w/ replies, xml ) Need Help??
HaB has asked for the wisdom of the Perl Monks concerning the following question:

Hello...

Experiencing the pitfalls of working with a module that is still in beta, and that the author hasn't finished documenting yet. In Win32::GUI, I am trying to create a toolbar, with 5 buttons, each of which should have a picture on it. I am using the toolbar.pl sample script that comes with Win32::GUI as a guideline, but I don't see many differences aside from the number of buttons I'm adding, (5) as opposed to what the sample script adds. (3)

So what I'm wondering is...does anyone know proper syntax/arguments for getting a bitmap onto a button? The documentation for Toolbars is not there, and only one bitmap method is described for Bitmap objects. The rest are TBD. I'm using the following code:

$main_toolbar = $main->AddToolbar( -left => 0, -top => 0, -width => $main->ScaleWidth-10, -height => 16, -name => "Toolbar" ); my $tb_bmp = Win32::GUI::Bitmap->new("c:\\devel\\adtserver_new\\toolba +r16.bmp"); $main_toolbar->SetBitmapSize(16,16); $main_toolbar->AddBitmap($tb_bmp, 5); $main_toolbar->AddButtons( 5, 0, 1, 4, 0, 0, 1, 2, 4, 0, 1, 2, 3, 4, 0, 2, 3, 4, 4, 0, 3, 4, 5, 4, 0, 4 );

I get the toolbar and the buttons, but they are blank, and henceforth not very useful. [; Also, any further help on what the args for AddButtons are used for would help immensely. I know the first arg is the number of buttons to add, and the 2nd column in each group of five is the number that's returned for the Click event. Everything else....*shrug* Anyone know what's up?


HaB


hword.

Comment on Win32::GUI Bitmaps on buttons?
Download Code
Re: Win32::GUI Bitmaps on buttons?
by Shendal (Hermit) on Nov 21, 2000 at 19:47 UTC
    The latest version of my Perl/Tk Newest Nodes Client uses bitmaps on the buttons. It's pretty rudamentary, but should show you the technique. I create the bitmap files (which are then stored in a hash) using a Solaris version of bitmap(1).

    Cheers,
    Shendal
      Er...
      I appreciate the response and all, but that doesn't really help me. The problem I'm having is specific to Win32::GUI, and I'm not using Tk. The docs for Bitmaps and Buttons are incomplete in that package, so I'm trying to find out if anyone knows the args and the arg order.


      HaB


      hword.
Re: Win32::GUI Bitmaps on buttons?
by the_slycer (Chaplain) on Nov 22, 2000 at 04:09 UTC
    Hmm.. not sure about the backgrounds/bitmaps for buttons. But here are the options..

    # (@)METHOD:new Win32::GUI::Button(PARENT, %OPTIONS)
    # Creates a new Button object;
    # can also be called as PARENT->AddButton(%OPTIONS).
    # Class specific %OPTIONS are:
    # -align => left/center/right (default left)
    # -valign => top/center/bottom
    #
    # -default => 0/1 (default 0)
    # -ok => 0/1 (default 0)
    # -cancel => 0/1 (default 0)

    I would assume that generic options would work with this as well (ie -color etc...). But, don't take my word for it, I've never used win32::gui.

    update: Played with it a little bit. Looks like what you need to do is something like this:
    $TB = $W->AddToolbar( -left => 0, -top => 0, -width => $W->ScaleWidth-10, -height => 100, -name => "Toolbar", ); $B = new Win32::GUI::Bitmap("unkfolder.bmp"); $C = new Win32::GUI::Bitmap("two.bmp"); $TB->SetBitmapSize(16, 16); $TB->AddBitmap($B, 1); $TB->AddBitmap($C, 2); $TB->AddString("ONE"); $TB->AddString("TWO"); $TB->AddButtons( 2, 0, 1, 4, 0, 0, 1, 2, 4, 0, 1, );
    That's pretty much stolen directly from the toolbar.pl sample. Basically, open the bitmaps, assign the size the bitmap will be on the toolbar, and then add the bitmaps to the relative button location (1,2,3 etc). Does that help?
    Another update:
    In the code above, ($B, 1) and ($C, 2) should read as ($B,0) and ($C,1).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://42700]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (13)
As of 2014-08-20 16:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (119 votes), past polls