Toolbar : DropDown Arrow button
Posted: Sun Jun 22, 2003 11:20 pm
How to create :
How to use :
You need a callback procedure to detect a click on arrow...
N.B. : I've not fund any ToolBarID command to retrieve the current TOOLBAR Handle.
That's why I use FindWindowEx

Code: Select all
*TB=CreateToolBar(#TOOLBAR_Main,*MainWindow)
LoadImage(#MENU_button,"buttonICO.ico")
ToolBarImageButton(#MENU_button,ImageID())
ToolBarDropDownArrow() ;before Tooltip init
ToolBarToolTip(#MENU_button,"button")
Code: Select all
; //////////////
; New ToolBar Procedure & Constants :
; //////////////
#TBN_DROPDOWN=-710
#TB_GETRECT=$400+51
#TBSTYLE_DROPDOWN=$8
#TBSTYLE_EX_DRAWDDARROWS=$1
#TB_SETEXTENDEDSTYLE=$400+84
#TB_GETEXTENDEDSTYLE=$400+85
Procedure ToolBarDropDownArrow()
*currentTB=FindWindowEx_(WindowID(), 0, "ToolbarWindow32", 0)
;change toolbar exStyle
exstyle=SendMessage_(*currentTB,#TB_GETEXTENDEDSTYLE,0,0)
SendMessage_(*currentTB,#TB_SETEXTENDEDSTYLE,0,exstyle | #TBSTYLE_EX_DRAWDDARROWS)
;change button style
pos=SendMessage_(*currentTB,#TB_BUTTONCOUNT,0,0)-1
SendMessage_(*currentTB,#TB_GETBUTTON,pos,button.TBBUTTON)
button\fsStyle=button\fsStyle | #TBSTYLE_DROPDOWN
SendMessage_(*currentTB,#TB_DELETEBUTTON,pos,0)
SendMessage_(*TB,#TB_INSERTBUTTON,pos+1,button)
EndProcedure
You need a callback procedure to detect a click on arrow...
Code: Select all
Procedure WindowCallBack(Window, Message, wParam, lParam)
If Message = #WM_Notify
; ===============
; Toolbar Notification
; ===============
*msgTB.nmToolbar=lParam
If *msgTB\hdr\hwndfrom = *TB
Select *msgTB\hdr\code
;bouton pickcolor
Case #TBN_DROPDOWN ;clicked on arrow !!
;///// Get asbolute position of the button
SendMessage_(*TB, #TB_GETRECT, *msgTB\iItem, @rc.RECT)
MapWindowPoints_(*TB,0, @rc, 2);
;///// Display Popup at position
DisplayPopupMenu(#MENU_Popup, *MainWindow, rc\left,rc\bottom)
ReturnValue = 0
EndSelect
EndIf
ProcedureReturn ReturnValue
EndProcedure

That's why I use FindWindowEx
