I agree that the Dropdown buttons are a challenge, and it sounds as
though you have progressed further than I got today. However this may be
because I have got two toolbars, each added to a band, and some of the
behaviour of a stand alone toolbar does not appear to work in this
combination... perhaps some of the glue is missing ;-)

I have not been able to get the text to appear to the right of the fifth
button (one with the dropdown). AddString does not appear to work.

>From the examples I have seen using C and VB you create a popupmenu. I
started looking at the examples and chasing down what was involved...

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/toolbar/styles.asp





BTNS_DROPDOWN 




Version 5.80. Creates a drop-down style button that can display a list
when the button is clicked. Instead of the WM_COMMAND message used for
normal buttons, drop-down buttons send a TBN_DROPDOWN notification. An
application can then have the notification handler display a list of
options. Use the equivalent style flag, TBSTYLE_DROPDOWN, for version
4.72 and earlier. 

If the toolbar has the TBSTYLE_EX_DRAWDDARROWS extended style, drop-down
buttons will have a drop-down arrow displayed in a separate section to
their right. If the arrow is clicked, a TBN_DROPDOWN notification will
be sent. If the associated button is clicked, a WM_COMMAND message will
be sent.

Note   Dropdown buttons can be plain (BTNS_DROPDOWN style), display an
arrow next to the button image (BTNS_WHOLEDROPDOWN style), or display an
arrow that is separated from the image (TBSTYLE_EX_DRAWDDARROWS style).
If a separated arrow is used, TBN_DROPDOWN is sent only if the user
clicks the arrow portion of the button. If the user clicks the main part
of the button, a WM_COMMAND message with button's ID is sent, just as
with a standard button. For the other two styles of dropdown button,
TBN_DROPDOWN is sent when the user clicks any part of the button.


To show dropdown menu you should handle TBN_DROPDOWN notification
message in OnNotify function.






Once you set the extended style TBSTYLE_EX_DRAWDDARROWS, if the main
part of the button (default) receives a click, the toolbar control sends
a WM_COMMAND. If the arrow is clicked a TBN_DROPDOWN notification is
sent which has to be intercepted and causes the dropdown menu (popup) to
be displayed. Thats about as far as I have got...

Very cut down example to demonstrate so far, the two toolbars in the
rebar (apologies for the formatting):

# =================================

use Win32::GUI; 

# Set Font 
$Font = new Win32::GUI::Font( 
#==================================== 
-name => "Tahoma", 
-size => 8, 
); 

# Load Bitmap 
$bmpSave = new Win32::GUI::Bitmap('.\Save.bmp'); 
$bmpSaveGrey = new Win32::GUI::Bitmap('.\SaveMsk.bmp'); 

# 32x32 pixel bitmap Images 
$IL32bmp = new Win32::GUI::ImageList(32, 32, 24,1,2); 
$IL32bmp->AddBitmap($bmpSaveGrey); 

# 32x32 pixel Hot bitmap Images 
$IL32Hotbmp = new Win32::GUI::ImageList(32, 32, 24, 1, 2); 
$IL32Hotbmp->AddBitmap($bmpSave); 

# Build the Menu 
$mMenu = Win32::GUI::MakeMenu( 
#==================================== 
"&File" => "mnuFile", 
" > &Open     Ctrl-O" => "mnuOpen", 
" > -" => 0, 
" > E&xit        Esc" => "mnuExit", 
); 

#==================================== 
# Set the Class for the window 
#==================================== 
$clsXPColourFix = Win32::GUI::Class->new( 
-name => "classxpcolour", 
-icon => $Icon, 
-cursor => $NormalCursor, 
-color => 16, 
); 

#==================================== 
# Construct the main Window 
#==================================== 
$mainwin = new Win32::GUI::Window( 
-class => $clsXPColourFix, 
-name => "mainwin", 
-title => "Toolbar Example", 
-left => 50, 
-top => 50, 
-width => 600, 
-height => 400, 
-minwidth => 600, 
-minheight => 400, 
-menu => $mMenu, 
#-accel => $AccelTable, 
-dialogui => 1, 
); 

# Status Bar 
$status = $mainwin->AddStatusBar( 
#==================================== 
-name => "status", 
) or die "new Statusbar. $!\n"; 

$status->Parts(500,-1); 
$status->PartText(0,"Example"); 

#==================================================================== 
# CONTROLS 
#==================================================================== 

# Rebar Control 
$rbrMainWin = $mainwin->AddRebar( 
#==================================== 
    -name => "rbrMainWin", 
-height => 64, 
-bandborders => 1, 
-doubleclick => 1, 
-varheight => 1, 
); 

# Main Toolbar 1 
$tbrMainWin1 = new Win32::GUI::Toolbar( 
#==================================== 
-parent => $mainwin->rbrMainWin, 
    -name => "tbrMainWin1", 
-imagelist => $IL32bmp, 
-style => TBSTYLE_FLAT|TBSTATE_ENABLED|TBSTYLE_TRANSPARENT, 
-nodivider => 1, 
-tooltip => 1, 
); 
$tbrMainWin1->SetHotImageList($IL32Hotbmp); 
$tbrMainWin1->SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS); 


$tbrMainWin1->AddButtons( 
#==================================== 
# (BITMAP,COMMAND,STATE,STYLE,STRING) 
    8, 
    0, 1, 4, 0, 0, 
0, 2, 4, 0, 1, 
0, 3, 4, 0, 2, 
0, 4, 4, 0, 3, 
0, 0, 0, 1, 0, 
0, 5, 4, 8, 4, 
0, 0, 0, 1, 0, 
0, 6, 4, 0, 5, 
); 

# Build Toolbar before adding to Band 
#==================================== 
$tbrMainWin1->DoEvents(); 

$mainwin->rbrMainWin->InsertBand ( 
  -child => $tbrMainWin1, 
  -index => 0, 
  -minheight => 34, 
  -width => 300, 
); 

# Main Toolbar 2 
$tbrMainWin2 = new Win32::GUI::Toolbar( 
#==================================== 
-parent => $mainwin->rbrMainWin, 
-name => "tbrMainWin2", 
-imagelist => $IL32bmp, 
-style => TBSTYLE_FLAT|TBSTATE_ENABLED|TBSTYLE_TRANSPARENT, 
-nodivider => 1, 
-tooltip => 1, 
); 
$tbrMainWin2->SetHotImageList($IL32Hotbmp); 

$tbrMainWin2->AddButtons( 
#==================================== 
# (BITMAP,COMMAND,STATE,STYLE,STRING) 
    1, 
0, 5, 4, 0, 4, 
); 

# Build Toolbar before adding to Band 
#==================================== 
$tbrMainWin1->DoEvents(); 

$mainwin->rbrMainWin->InsertBand ( 
-child => $tbrMainWin2, 
-index => 1, 
-minheight => 34, 
-width => 40, 
); 



$mainwin->Show; 
$mainwin->Show; 

my $retcode = Win32::GUI::Dialog(); 



# =================== 
# MAIN WINDOW EVENTS 
# =================== 

# Window and widget resizer 
sub mainwin_Resize { 
#==================================== 
if(defined $mainwin) { 
my $w = $mainwin->ScaleWidth(); 
my $h = $mainwin->ScaleHeight(); 
# 

$status->Width($mainwin->ScaleWidth); 
$status->Top($mainwin->ScaleHeight - $status->Height); 
} 
} 


# Exit from menu 
sub mnuExit_Click { 
#==================================== 
mainwin_Terminate(); 
} 

# =================== 
# KILL WINDOW 
# =================== 

# Kill Application 
sub mainwin_Terminate { 
#==================================== 
# Close Database connection 

$mainwin->Disable(); 
$mainwin->Hide(); 

return -1; 
} 

END {} 


__END__

On Thu, 2004-12-02 at 21:05, Frazier, Joe Jr wrote: 

> Np, I learned from this as well, so its all good.  Now.... from your
> example I also played around and was wondering if anyone had played
> with dropdown buttons?  Mainly, I have not been able to get the
> _ButtonClick event to capture events on the extended dropdown section
> of a button.  I was able to get the event in a Toolbar_Click event and
> comparing the hotitem to the correct button's index, but this then
> also sends the _ButtonClick event as well.
>  
> Also, is there a way to style popup menus?  I am looking for something
> like Excel's Autosum button, which displays a "white" menu with a flat
> border ( as opposed to the normal menu's raised 3d effect).
>  
>  
>  
>  
> Joe Frazier, Jr.
> Senior Support Engineer
> 
> Peopleclick Service Support
> Tel:  +1-800-841-2365
> E-Mail: [EMAIL PROTECTED]
>  
> 
>         
>         ______________________________________________________________
>         From: Chris Wearn [mailto:[EMAIL PROTECTED] 
>         Sent: Wednesday, December 01, 2004 8:52 PM
>         To: Frazier, Joe Jr
>         Cc: perl-win32-gui-users@lists.sourceforge.net
>         Subject: RE: [perl-win32-gui-users] Revisited - Rebar and
>         Toolbars
>         
>         
>         Sensational! Thanks Joe, 
>         
>         I tried all sorts of things to get rid of it. However, I
>         skipped that one completely, wrongly assuming it was a
>         vertical divider between the button objects, similar to
>         TBSTYLE_SEP.
>         
>         Chris
>         
>         On Thu, 2004-12-02 at 01:15, Frazier, Joe Jr wrote: 
>         
>         > After playing with this for a while:
>         >  
>         >  
>         > $TB = new Win32::GUI::Toolbar( 
>         >     $W->Rebar, 
>         >     -name   => "Toolbar", 
>         >     -width  => 100, 
>         >     -style  => 2048 + 8 + 4, 
>         >     -width  => 100, 
>         >     -height => 22, 
>         >     -nodivider => 1,   # add this to remove the line above
>         > the toolbar.
>         >  
>         > ); 
>         > 
>         >  
>         > 
>         > Joe Frazier, Jr.
>         > Senior Support Engineer
>         > 
>         > Peopleclick Service Support
>         > Tel:  +1-800-841-2365
>         > E-Mail: [EMAIL PROTECTED]
>         > 
>         >   
>         > 
>         >         
>         >         ____________________________________________________
>         >         From:
>         >         [EMAIL PROTECTED]
>         >         [mailto:[EMAIL PROTECTED] On Behalf Of Chris Wearn
>         >         Sent: Wednesday, December 01, 2004 7:51 AM
>         >         To: perl-win32-gui-users@lists.sourceforge.net
>         >         Subject: [perl-win32-gui-users] Revisited - Rebar
>         >         and Toolbars
>         >         
>         >         
>         >         Hi All,
>         >         
>         >         Have spent a few hours revisiting the old threads
>         >         regarding the use of the Rebar control.
>         >         
>         >         It would appear that you can only have one control
>         >         per Band, and this was overcome by inserting a
>         >         borderless window into each band.
>         >         
>         >         However, reading the documentation from MSDN and an
>         >         O'Reilly 'Visual Basic Controls - in a nutshell' on
>         >         topics for "coolbar" (rebar), it mentions that each
>         >         band of the rebar control serves as a container and
>         >         that the most common use is to be placed on an SDI
>         >         or MDI window, so that multiple TOOLBAR controls can
>         >         be contained within it, one in each Band object.
>         >         This then allows as many controls as you need to be
>         >         placed in the Toolbar, which is then made a Child of
>         >         the Band.
>         >         
>         >         An example that I found, demonstrating this is at
>         >         the end of this email.
>         >         
>         >         I noticed that I could not "AddToolbar" to a Band or
>         >         Rebar and had to use the 'new' method (as per the
>         >         example).
>         >         
>         >         This method all seems to work fine, even the
>         >         mouse-over (hot) type image changes work, HOWEVER...
>         >         If you run the example, you will notice a thin line
>         >         above the toolbar. This does not appear to be part
>         >         of the Band or Rebar settings and looks like it may
>         >         be the BorderStyle of the Toolbar.
>         >         
>         >         MS and VB documentation lists a default property of
>         >         "ccFixedSingle" but should be changed to "ccNone"
>         >         when used in a Rebar.
>         >         
>         >         I have searched all the Win32 API constants I can
>         >         find, and can't work out how to set or remove this
>         >         property either as a -borderstyle => 1, method or
>         >         -style => TB_FIXEDSINGLE (example) style.
>         >         
>         >         Anyone have any ideas... or is it missing a bit in
>         >         the XS ??
>         >         
>         >         Rgds
>         >         
>         >         Chris Wearn
>         >         
>         >         # ====== Rebar.pl example ==============
>         >         
>         >         use Win32::GUI; 
>         >         
>         >         # just for debugging/testing purposes... 
>         >         use Win32::API; 
>         >         $GetDlgCtrlID = new Win32::API("user32",
>         >         "GetDlgCtrlID", [N], N); 
>         >         
>         >         $W = new Win32::GUI::Window( 
>         >             -name => "Window", 
>         >             -text => "Win32::GUI::Rebar test", 
>         >             -left => 100, 
>         >             -top => 100, 
>         >             -width => 200, 
>         >             -height => 300, 
>         >         ); 
>         >         $W->Text("Win32::GUI::Rebar test"); 
>         >         
>         >         new Win32::GUI::Rebar( 
>         >             $W, 
>         >             -name => "Rebar", 
>         >             -text => "I'm a placeholder", 
>         >             -left => 0, 
>         >             -top => 0, 
>         >             -width => 200, 
>         >             -height => 50, 
>         >             -menu => 33, 
>         >         ); 
>         >         if(!$W->Rebar) { 
>         >             print "Error creating Rebar: ",
>         >         Win32::GetLastError(), "\n"; 
>         >         } 
>         >         
>         >         $TB = new Win32::GUI::Toolbar( 
>         >             $W->Rebar, 
>         >             -name   => "Toolbar", 
>         >             -width  => 100, 
>         >             -style  => 2048 + 8 + 4, 
>         >             -width  => 100, 
>         >             -height => 22, 
>         >         ); 
>         >         
>         >         $B = new Win32::GUI::Bitmap("tools.bmp"); 
>         >         
>         >         $TB->SetBitmapSize(16, 16); 
>         >         
>         >         $TB->AddBitmap($B, 3); 
>         >         
>         >         $TB->AddString("One"); 
>         >         $TB->AddString("Two"); 
>         >         $TB->AddString("Three"); 
>         >         
>         >         $TB->AddButtons( 
>         >             3, 
>         >             0, 1, 4, 0, 0, 
>         >             1, 2, 4, 0, 1, 
>         >             2, 3, 4, 0, 2, 
>         >         ); 
>         >         
>         >         $BK = new Win32::GUI::Bitmap("zapotec.bmp"); 
>         >         
>         >         $W->Rebar->InsertBand( 
>         >             -child => $TB, 
>         >             -width => 16*4, 
>         >             -minwidth => 100, 
>         >             -minheight => $TB->Height*2, 
>         >             -bitmap => $BK, 
>         >         ); 
>         >         
>         >         $E = new Win32::GUI::Textfield( 
>         >         #     $W->Rebar, 
>         >             $W, 
>         >             -name       => "Textfield", 
>         >             -text       => "Hello world!", 
>         >             -width      => 100, 
>         >             -height     => 22, 
>         >             -background => [0, 255, 0], 
>         >             -foreground => [255, 0, 0], 
>         >             -menu       => 55, 
>         >         ); 
>         >         
>         >         $W->Rebar->InsertBand( 
>         >             -text => "Text:", 
>         >             -child => $E, 
>         >             -width => 100, 
>         >             -minwidth => 100, 
>         >             -minheight => $E->Height, 
>         >             -background => [0, 255, 0], 
>         >             -foreground => [255, 128, 128], 
>         >         ); 
>         >         
>         >         $W->AddTextfield( 
>         >             -name => "Info", 
>         >             -left => 0, 
>         >             -top  => $W->Rebar->Height, 
>         >             -width => $W->ScaleWidth, 
>         >             -height => $W->ScaleHeight-$W->Rebar->Height, 
>         >             -multiline => 1, 
>         >         ); 
>         >         
>         >         print "R.BANDCOUNT = ",
>         >         $W->Rebar->SendMessage(1024+12, 0, 0), "\n"; 
>         >         print "R.ROWCOUNT = ",
>         >         $W->Rebar->SendMessage(1024+13, 0, 0), "\n"; 
>         >         print "R.ROWHEIGHT = ",
>         >         $W->Rebar->SendMessage(1024+14, 0, 0), "\n"; 
>         >         
>         >         $W->Show(); 
>         >         
>         >         # $W->Rebar->Show(); 
>         >         
>         >         Win32::GUI::Dialog(); 
>         >         
>         >         sub Window_Terminate { 
>         >             return -1; 
>         >         } 
>         >         
>         >         sub Window_Resize { 
>         >             $W->Rebar->Resize($W->ScaleWidth,
>         >         $W->ScaleHeight); 
>         >             $W->Info->Move(0, $W->Rebar->Height); 
>         >             $W->Info->Resize( 
>         >                 $W->ScaleWidth, 
>         >                 $W->ScaleHeight-$W->Rebar->Height, 
>         >             ); 
>         >         } 
>         >         
>         >         sub Toolbar_ButtonClick { 
>         >             my($button) = @_; 
>         >             $W->Info->Text("You pressed the
>         >         button:\r\n".$button); 
>         >             $i = $GetDlgCtrlID->Call($W->Rebar->{-handle}); 
>         >             print "Rebar.ID = $i\n"; 
>         >             $i =
>         >         $GetDlgCtrlID->Call($W->Textfield->{-handle}); 
>         >             print "Textfield.ID = $i\n"; 
>         >         } 
>         >         
>         >         sub Textfield_Change { 
>         >             $W->Info->Text("You typed:\r\n".$E->Text); 
>         >         } 
>         >         
>         >         sub Rebar_HeightChange { 
>         >             if(exists($W->{Info})) { 
>         >                 $W->Info->Move(0, $W->Rebar->Height); 
>         >                 $W->Info->Resize( 
>         >                     $W->ScaleWidth, 
>         >                     $W->ScaleHeight-$W->Rebar->Height, 
>         >                 ); 
>         >             } 
>         >         } 

<<attachment: smiley-4.png>>

Reply via email to