ToolBarImageButton()

Syntax

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

Parameters

#Button The new toolbar button identifier.
ImageID The image to use for the button. It 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, use the PNG file format.
Mode (optional) The mode value can be one of the following constants:
  #PB_ToolBar_Normal: the button will act as standard button (default)
  #PB_ToolBar_Toggle: the button will act as toggle button
GetToolBarButtonState() and SetToolBarButtonState() can be used to retrieve or modify a toggle button state.

Return value

None.

Example

  Procedure MenuEvents()
    Debug "ToolBar item selected: " + EventMenu()
  EndProcedure
  
  If OpenWindow(0, 0, 0, 295, 260, "ToolBar example", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
    
    CreateImage(0, 16, 16, 32, #PB_Image_Transparent)
    If StartDrawing(ImageOutput(0))
      Circle(8, 8, 7, RGB(255, 0, 0))
      StopDrawing()
    EndIf
    
    If CreateToolBar(0, WindowID(0))
      ToolBarImageButton(0, ImageID(0), #PB_ToolBar_Toggle)
      ToolBarToolTip(0, 0, "Open")
      ToolBarImageButton(1, ImageID(0))
      ToolBarToolTip(0, 1, "Save")
    EndIf
      
    BindEvent(#PB_Event_Menu, @MenuEvents())
  EndIf

See Also

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