Yep, it will shift down to the bottom when you do SetStyle because you're 
replacing the styles. The common control style CCS_TOP is applied by default on 
new toolbars, but as soon as you do SetStyle you remove this style unless you 
explicitly add it into your setstyle call.

CCS_TOP is defined as 1, so to make the toolbar appear at the top of the window 
with setstyle use:
$TB->SetStyle(TBSTYLE_FLAT|TBSTYLE_TRANSPARENT|1);

I'm unsure as to whether to put this in by default. I think I'll add an option 
to the constructor so that you can specify where the toolbar is.

Steve

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] 
> Behalf Of
> Jez White
> Sent: 18 February 2004 10:03
> To: Steve Pick; Win32 GUI Hackers (E-mail)
> Subject: Re: [perl-win32-gui-hackers] CVS update: Toolbars
> 
> 
> Hi,
> 
> I've had a play and it seems ok - although I'm having a few 
> problems with
> some of the styles - but this could be me:)
> 
> The example below creates a toolbar with a few buttons (run 
> in the samples
> folder for it to pick up the bitmaps) which are added via image lists.
> If I use the SetStyle method (with any style) the toolbar 
> ends up at the
> bottem of the window. I've yet to get any functionality working with
> SetExtendedStyle (I was trying to get tooltips working with 
> the toolbar
> using the text from the buttons).
> 
> Just me?
> 
> Cheers,
> 
> jez.
> ==============
> 
> use Win32::GUI;
> 
> $W = new Win32::GUI::Window(
>     -title    => "Win32::GUI::Toolbar test",
>     -left     => 100,
>     -top      => 100,
>     -width    => 500,
>     -height   => 400,
>     -name     => "Window",
> );
> 
> $B1 = new Win32::GUI::Bitmap("one.bmp");
> $B2 = new Win32::GUI::Bitmap("two.bmp");
> $B3 = new Win32::GUI::Bitmap("three.bmp");
> $IL = new Win32::GUI::ImageList(16, 16, 0, 3, 10);
> $IL->Add($B1, 0);
> $IL->Add($B2, 0);
> $IL->Add($B3, 0);
> 
> $TB = $W->AddToolbar(
>     -left   =>  0,
>     -top    =>  0,
>     -width  => 300,
>     -height => 100,
>     -name   => "Toolbar",
>     -addstyle =>  0x0800,
> );
> $TB->SetImageList($IL);
> #$TB->SetStyle(TBSTYLE_FLAT|TBSTYLE_TRANSPARENT);
> #$TB->SetExtendedStyle(TBSTYLE_EX_MIXEDBUTTONS|TBSTYLE_EX_DRAW
> DDARROWS);
> $Bh1 = new Win32::GUI::Bitmap("three.bmp");
> $Bh2 = new Win32::GUI::Bitmap("one.bmp");
> $Bh3 = new Win32::GUI::Bitmap("two.bmp");
> $ILhot = new Win32::GUI::ImageList(16, 16, 0, 3, 10);
> $ILhot->Add($Bh1, 0);
> $ILhot->Add($Bh2, 0);
> $ILhot->Add($Bh3, 0);
> $TB->SetHotImageList($ILhot);
> $TB->AddButtons(
>     4,
>     0, 1, 4, 0, 0,
>     1, 2, 4, 0, 1,
>     0, 0, 0, TBSTYLE_SEP, 0,
>     2, 3, 4, 0, 2,
> );
> $TB->AddString("One");
> $TB->AddString("Two");
> $TB->AddString("Three");
> 
> $W->Show;
> 
> Win32::GUI::Dialog();
> 
> 
> sub Window_Terminate {
>     return -1;
> }
> 
> sub Window_Resize {
>     $TB->Resize($W->ScaleWidth-10, 100);
> }
> 
> sub Toolbar_ButtonClick {
>     my($button) = @_;
>     print "Toolbar: clicked button $button\n";
> }
> 
> 
> 
> -------------------------------------------------------
> SF.Net is sponsored by: Speed Start Your Linux Apps Now.
> Build and deploy apps & Web services for Linux with
> a free DVD software kit from IBM. Click Now!
> http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
> _______________________________________________
> Perl-Win32-GUI-Hackers mailing list
> Perl-Win32-GUI-Hackers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-hackers
> 

Reply via email to