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.

The dimensions of the images are 16x16 pixels.

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

  UsePNGImageDecoder()

    If CreateImage(0,16,16,32)
      StartDrawing(ImageOutput(0))
      Box(0,0,15,15,RGB(255,255,128))
      DrawRotatedText(-5,3, "+", 45, RGB(255,0,128))
      StopDrawing()
    EndIf

  If OpenWindow(0, 200, 200, 200, 120, "Image Popup-Menu Example")

    If LoadImage(1,#PB_Compiler_Home + "Examples\Sources\Data\ToolBar\Open.png")  ; load an icon
    If CreatePopupImageMenu(0, #PB_Menu_ModernLook)      ; creation of the pop-up menu begins...
      MenuItem(1, "Open", ImageID(1))      ; Display the icon
      MenuItem(2, "Save")      ; just like in a normal menu...
      MenuItem(3, "Save as")
      MenuItem(4, "Quit", ImageID(0)) ; Display our own icon
      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
  EndIf

See Also

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

Supported OS

All

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