CreateToolBar()

Syntax

Result = CreateToolBar(#ToolBar, WindowID [, Flags])
Description
Creates a new empty toolbar on the given window.

Parameters

#ToolBar A number to identify the new toolbar. #PB_Any can be used to auto-generate this number.
WindowID The window for the new toolbar. It can be obtained using the WindowID() function.
Flags (optional) It can be a combination of the following values:
  #PB_ToolBar_Small     : Small icon (16x16 pixels) toolbar (default) 
  #PB_ToolBar_Large     : Large icon (24x24 pixels) toolbar
  #PB_ToolBar_Text      : Text will be displayed below the button
  #PB_ToolBar_InlineText: Text will be displayed at the right of the button (Windows only)

Return value

Returns nonzero if the toolbar was created successfully and zero if not. If #PB_Any was used for the #ToolBar parameter then the generated number is returned on success.

Remarks

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

The events are handled the same way than menu events, using the function EventMenu(). ToolBars are often used as shortcut for menu items, so when assigning the same menu item number to a toolbar button, both events are handled using the same code.

Example

 If OpenWindow(0, 0, 0, 150, 25, "ToolBar", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    If CreateToolBar(0, WindowID(0))
      UsePNGImageDecoder()
      Path$ = #PB_Compiler_Home  + "Examples" + #PS$ + "Sources" + #PS$ + "Data" + #PS$ + "ToolBar" + #PS$ + ""
      ToolBarImageButton(0, LoadImage(0, Path$ + "New.png"))
      ToolBarImageButton(1, LoadImage(1, Path$ + "Open.png"))
      ToolBarImageButton(2, LoadImage(2, Path$ + "Save.png"))
    EndIf
    Repeat
      Event = WaitWindowEvent()
      If Event = #PB_Event_Menu
        Debug "ToolBar ID: "+Str(EventMenu())
      EndIf
    Until Event = #PB_Event_CloseWindow 
  EndIf

See Also

ToolBarImageButton(), ToolBarSeparator(), FreeToolBar()

Supported OS

All

ToolBar Index - DisableToolBarButton() ->