Toolbar button w/ drop down?
Posted: Tue Nov 22, 2011 4:39 pm
Am I right in that there is no native "drop down" toolbar item?
http://www.purebasic.com
https://www.purebasic.fr/english/
This would be my guess.IdeasVacuum wrote:...I think it is an icon toolbar where holding the left-mouse on a toolbar button invokes a drop-down toolbar of other buttons.
Code: Select all
Procedure WinProc(hwnd, msg, wparam, lparam)
result=#PB_ProcessPureBasicEvents
Select msg
Case #WM_NOTIFY
*nmt.NMTOOLBAR = lparam
Select *nmt\hdr\code
Case #TBN_DROPDOWN
MapWindowPoints_( WindowID(0), 0, *nmt\rcButton, 2)
DisplayPopupMenu(1, WindowID(0),*nmt\rcButton\left,*nmt\rcButton\bottom)
ProcedureReturn 0
EndSelect
EndSelect
ProcedureReturn result
EndProcedure
OpenWindow(0, 100, 200, 640, 480, "ToolBar example", #PB_Window_SystemMenu | #PB_Window_SizeGadget)
SetWindowCallback(@WinProc())
bar = CreateToolBar(0, WindowID(0))
SendMessage_(bar, #TB_SETBUTTONSIZE, 0, 48|24<<16)
SendMessage_(bar, #TB_SETEXTENDEDSTYLE, 0, #TBSTYLE_EX_DRAWDDARROWS)
ToolBarStandardButton(0, #PB_ToolBarIcon_New)
ToolBarStandardButton(1, #PB_ToolBarIcon_Open)
ToolBarStandardButton(2, #PB_ToolBarIcon_Save)
With tbbi.TBBUTTONINFO
\dwMask = #TBIF_BYINDEX|#TBIF_STYLE
\cbSize = SizeOf(TBBUTTONINFO)
EndWith
SendMessage_(bar, #TB_GETBUTTONINFO, 2, @tbbi)
tbbi\fsStyle|#BTNS_DROPDOWN
SendMessage_(bar, #TB_SETBUTTONINFO, 2, @tbbi)
If CreateMenu(0, WindowID(0))
MenuTitle("Project")
MenuItem(0, "New")
MenuItem(1, "Open")
MenuItem(2, "Save")
EndIf
CreatePopupMenu(1)
MenuItem(9, "Option 1")
MenuItem(10, "Option 2")
MenuItem(11, "Option 3")
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Menu
MessageRequester("Information", "ToolBar or Menu ID: "+Str(EventMenu()), 0)
Case #PB_Event_CloseWindow
Quit=1
EndSelect
Until Quit
Thanks for the example... I'm doing some work; and the client is leaning towards RealBasic; so I want to be sure I can do everything their asking in PureBasic...netmaestro wrote:It's actually pretty easy with a popup menu, if all you're looking for is a dropdown with options: