DisableToolBarButton()

Syntax

DisableToolBarButton(#ToolBar, Button, State)
Description
Disable (or enable) a toolbar button in the given toolbar.

Parameters

#ToolBar The toolbar to use.
Button The toolbar button to disable or enable.
State The new state for the toolbar button. A value of 1 disables the toolbar button and a value of 0 enables it.

Return value

None.

Example

If OpenWindow(0, 0, 0, 180, 60, "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"))
      DisableToolBarButton(0, 1, 1) : Disabled = #True
    EndIf

    ButtonGadget(0, 10, 30, 130, 20, "Enable OpenFile")
    ResizeGadget(0, #PB_Ignore, #PB_Ignore, GadgetWidth(0, #PB_Gadget_RequiredSize), #PB_Ignore)
    
    Repeat
      Event = WaitWindowEvent()
      If Event = #PB_Event_Gadget
        If EventGadget() = 0
          If Disabled = #True
            DisableToolBarButton(0, 1, 0)
            SetGadgetText(0,"Disable OpenFile")
            ResizeGadget(0, #PB_Ignore, #PB_Ignore, GadgetWidth(0, #PB_Gadget_RequiredSize), #PB_Ignore)
            Disabled = #False
          Else
            DisableToolBarButton(0, 1, 1)
            SetGadgetText(0,"Enable OpenFile")
            ResizeGadget(0, #PB_Ignore, #PB_Ignore, GadgetWidth(0, #PB_Gadget_RequiredSize), #PB_Ignore)
            Disabled = #True
          EndIf
        EndIf
      EndIf
    Until Event = #PB_Event_CloseWindow 
  EndIf

See Also

ToolBarImageButton()

Supported OS

All

<- CreateToolBar() - ToolBar Index - FreeToolBar() ->