ToolBarImageButton()

Syntax

ToolBarImageButton(#ButtonID, ImageID [, Mode])
Description
Add an image button to the toolbar being constructed. CreateToolBar() must be called before to use this command.

The 'ImageID' can be easily obtained by using ImageID() from the Image library. It can be an image loaded with LoadImage() or created in memory with CreateImage(). To have a real transparent background, the 'icon' (.ico) file format is recommanded.

With the optional 'Mode' parameter can be adjusted, if the ToolBarImageButton will act as a toggle button or not. One of the following constants can be used:
  #PB_ToolBar_Normal: the button will act as standard button (default setting)
  #PB_ToolBar_Toggle: the button will act as toggle button
Later the GetToolBarButtonState() and SetToolBarButtonState() commands can be used on it.

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)
    CreateImage(0,16,16)
    StartDrawing(ImageOutput(0))
      Box(0,0,16,16,RGB(255,255,255))
      Box(4,4,8,8,RGB(255,0,0))
    StopDrawing()
    CreateImage(1,16,16)
    StartDrawing(ImageOutput(1))
      Box(0,0,16,16,RGB(255,0,0))
      Box(4,4,8,8,RGB(255,255,255))
    StopDrawing()
    If CreateToolBar(0, WindowID(0))
      ToolBarImageButton(0,ImageID(0))
      ToolBarImageButton(1,ImageID(1))
    EndIf
    Repeat
    Until WaitWindowEvent() = #PB_Event_CloseWindow 
  EndIf

Supported OS

Windows, Linux, MacOS X

<- ToolBarID() - ToolBar Index - ToolBarSeparator() ->