ToolBarImageButton()

Syntax

ToolBarImageButton(#ButtonID, ImageID)
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 UseImage() or 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.

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 EventMenuID().

Example:
  If OpenWindow(0, 0, 0, 150, 25, #PB_Window_SystemMenu |#PB_Window_ScreenCentered, "ToolBar")
    CreateImage(0,16,16)
    StartDrawing(ImageOutput())
      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())
      Box(0,0,16,16,RGB(255,0,0))
      Box(4,4,8,8,RGB(255,255,255))
    StopDrawing()
    If CreateToolBar(0, WindowID())
      ToolBarImageButton(0,UseImage(0))
      ToolBarImageButton(1,UseImage(1))
    EndIf
    Repeat
    Until WaitWindowEvent() = #PB_Event_CloseWindow 
  EndIf

Supported OS

Windows, Linux, MacOS X

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