Toolbar button w/ drop down?

Just starting out? Need help? Post your questions and find answers here.
jassing
Addict
Addict
Posts: 1774
Joined: Wed Feb 17, 2010 12:00 am

Toolbar button w/ drop down?

Post by jassing »

Am I right in that there is no native "drop down" toolbar item?
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Toolbar button w/ drop down?

Post by IdeasVacuum »

Well, there isn't a native toolbar to drop it from.......
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Zach
Addict
Addict
Posts: 1656
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Toolbar button w/ drop down?

Post by Zach »

I think he means a selection box, like the selection boxes on an Open File dialog to choose the file type filter, or recall a previously entered path/file
Image
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Toolbar button w/ drop down?

Post by IdeasVacuum »

...I think it is an icon toolbar where holding the left-mouse on a toolbar button invokes a drop-down toolbar of other buttons.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Kuron
Addict
Addict
Posts: 1626
Joined: Sat Oct 17, 2009 10:51 pm
Location: Pacific Northwest

Re: Toolbar button w/ drop down?

Post by Kuron »

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.
This would be my guess. :wink:
Best wishes to the PB community. Thank you for the memories. ♥️
Zach
Addict
Addict
Posts: 1656
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Toolbar button w/ drop down?

Post by Zach »

Oh, those things..

Only place I've seen something similar to them available is in using ProGUI. I think you need to use a Rebar to get those. But assuming you can conjur up a Rebar via API, I would assume it can be done in standard PB.

It is demonstrated in RebarExample2.exe and ToolBarExample.exe from the samples pack download.
Image
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8433
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Toolbar button w/ drop down?

Post by netmaestro »

It's actually pretty easy with a popup menu, if all you're looking for is a dropdown with options:

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
BERESHEIT
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Toolbar button w/ drop down?

Post by IdeasVacuum »

Well, the first lesson learnt from netmaestro's excellent code is - scroll down to the bottom of the help menu! I never knew CreateToolBar was there (may be because I expected it to be described as a Gadget).
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
jassing
Addict
Addict
Posts: 1774
Joined: Wed Feb 17, 2010 12:00 am

Re: Toolbar button w/ drop down?

Post by jassing »

netmaestro wrote:It's actually pretty easy with a popup menu, if all you're looking for is a dropdown with options:
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...
Post Reply