GetMenuItemState()

Syntax

Result = GetMenuItemState(#Menu, MenuItem)
Description
Returns the checkbox state of a menu item.

Parameters

#Menu The menu to use.
MenuItem The menu item number to get the state of.

Return value

Returns nonzero if the menu item is checked and zero otherwise.

Remarks

Use SetMenuItemState() to change the state of a menu item.

Example

  If OpenWindow(0, 200, 200, 200, 100, "GetMenuItemState Example")
    If CreateMenu(0, WindowID(0))
      MenuTitle("Project")
        MenuItem(1, "Changed")
        SetMenuItemState(0, 1, 1)        ; set check mark for the previously created menu item
    EndIf
    Repeat
      Event = WaitWindowEvent()          ; wait for an event
      If Event = #PB_Event_Menu          ; a menu event appeared
        If EventMenu() = 1               ; first menu item was clicked
          If GetMenuItemState(0, 1) = 1  ; actual item state = check marked
            SetMenuItemState(0, 1, 0)    ; now remove the check mark
          Else                           ; actual item state = no check mark
            SetMenuItemState(0, 1, 1)    ; now set the check mark
          EndIf
        EndIf
      EndIf
    Until Event = #PB_Event_CloseWindow
  EndIf

See Also

SetMenuItemState(), GetMenuItemText(), MenuItem()

Supported OS

All

<- FreeMenu() - Menu Index - GetMenuItemText() ->