CreateImageMenu()

Syntax

Result = CreateImageMenu(#Menu, WindowID [, Flags])
Description
Creates a new empty menu on the given window with support for images in the menu items.

Parameters

#Menu A number to identify the new menu. #PB_Any can be used to auto-generate this number.
WindowID The window for the new menu. It can be obtained using the WindowID() function.
Flags (optional) Not used.

Return value

Nonzero if the menu was successfully created, zero otherwise. If #PB_Any was used for the #Menu parameter then the generated number is returned on success.

Remarks

Once created, this menu becomes the current menu for further item additions. It's now possible to use functions such as MenuTitle(), MenuItem(), MenuBar(), OpenSubMenu() to populate the menu.

To handle menu events, use BindEvent(), EventWindow() and EventMenu().

Example

  Procedure MenuEvents()
    Debug "Menu item selected: " + EventMenu()
  EndProcedure
  
  CreateImage(0, 16, 16)
  If StartDrawing(ImageOutput(0))
    Box(0, 0, 16, 16, RGB(255, 0, 0)) ; red box
    StopDrawing()
  EndIf
  
  
  If OpenWindow(0, 200, 200, 200, 100, "Menu Example")
    If CreateMenu(0, WindowID(0))    ; menu creation starts....
      MenuTitle("Project")
      MenuItem(1, "Open", ImageID(0))
      MenuItem(2, "Save")
      MenuItem(3, "Save as")
      MenuItem(4, "Close", ImageID(0))
    EndIf
    
    BindEvent(#PB_Event_Menu, @MenuEvents())
  EndIf

See Also

CreateMenu(), CreatePopupMenu(), CreatePopupImageMenu(), FreeMenu(), MenuTitle(), MenuItem(), MenuBar(), OpenSubMenu()

Supported OS

All

<- CloseSubMenu() - Menu Index - CreateMenu() ->