CreatePopupImageMenu()

Syntax

Result = CreatePopupImageMenu(#Menu [, Flags])
Description
Creates a new empty popup menu, with image support for its items.

Parameters

#Menu A number to identify the new menu. #PB_Any can be used to auto-generate this number.
Flags (optional) This can be a combination of the following values:
  #PB_Menu_ModernLook: Enable gradient and modern look (only has an effect on Windows)

Return value

Returns nonzero if the menu was created successfully and zero if not. 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.

DisplayPopupMenu() can be used to display this popup menu at any position on the screen.

To handle menu events properly, see the description of following functions:
WaitWindowEvent() (alternatively WindowEvent())
EventWindow()
EventMenu()

Example

  If OpenWindow(0, 200, 200, 200, 120, "Image Popup-Menu Example")
  
    If CreatePopupImageMenu(0, #PB_Menu_ModernLook)      ; creation of the pop-up menu begins...
      MenuItem(1, "Open")      ; You can use all commands for creating a menu
      MenuItem(2, "Save")      ; just like in a normal menu...
      MenuItem(3, "Save as")
      MenuItem(4, "Quit")
      MenuBar()
      OpenSubMenu("Recent files")
        MenuItem(5, "PureBasic.exe")
        MenuItem(6, "Test.txt")
      CloseSubMenu()
    EndIf
    
    Repeat
      Event = WaitWindowEvent()     ; check for window events
      
      Select Event
        Case #PB_Event_RightClick  ; right mouse button was clicked =>
          DisplayPopupMenu(0, WindowID(0))  ; now display the popup-menu
          
        Case #PB_Event_Menu        ; an item of the popup-menu was clicked
          Select EventMenu()       ; get the clicked menu item...
            Case 1 : Debug "Menu: Open"
            Case 2 : Debug "Menu: Save"
            Case 3 : Debug "Menu: Save as"
            Case 4 : End
            Case 5 : Debug "Menu: PureBasic.exe"
            Case 6 : Debug "Menu: Text.txt"
          EndSelect
          
      EndSelect
    Until Event = #PB_Event_CloseWindow
  EndIf

See Also

CreatePopupMenu(), DisplayPopupMenu(), CreateMenu(), CreateImageMenu(), FreeMenu(), MenuTitle(), MenuItem(), MenuBar(), OpenSubMenu()

Supported OS

All

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