CreateToolBar()

Syntax

Result = CreateToolBar(#ToolBar, WindowID)
Description
Create an empty toolbar identified by the number '#ToolBar' on the given window. If #PB_Any is used as '#Toolbar' parameter, the new toolbar number will be returned as 'Result'. WindowID can be easily obtained with the WindowID() command.

This toolbar become the default toolbar for creation and it's possible to use ToolBarStandardButton(), ToolBarImageButton() and ToolBarSeparator() to add some elements to this toolbar.

If the 'Result' is 0, the toolbar can't be created, else all is fine.

The later checking of an event, means if the user clicked on an item of the toolbar, will done the same way like checking for a menu event with the command EventMenu().

Example:
  If OpenWindow(0, 0, 0, 150, 25, "ToolBar", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    If CreateToolBar(0, WindowID(0))
      ToolBarStandardButton(0, #PB_ToolBarIcon_New)
      ToolBarStandardButton(1, #PB_ToolBarIcon_Open)
      ToolBarStandardButton(2, #PB_ToolBarIcon_Save)
    EndIf
    Repeat
      Event = WaitWindowEvent()
      If Event = #PB_Event_Menu
        Debug "ToolBar ID: "+Str(EventMenu())
      EndIf
    Until Event = #PB_Event_CloseWindow 
  EndIf

Supported OS

Windows, Linux, MacOS X

ToolBar Index - DisableToolBarButton() ->