CreatePopupMenu()
Syntax
Result = CreatePopupMenu(#Menu)Description
Creates a new empty popup menu. If #PB_Any is used as '#Menu' parameter, the new menu number will be returned as 'Result'. If the menu can't be created, 'Result' will be 0. It becomes the currently menu for building. It's now possible to use the commands like MenuItem(), MenuBar(), OpenSubMenu() etc...
DisplayPopupMenu() can be used to display this popup menu at any position on the screen.
To handle all menu events properly, see the description of following commands:
WaitWindowEvent() (alternatively WindowEvent())
EventWindow()
EventMenu()
Example:If OpenWindow(0, 200, 200, 200, 120, "Popup-Menu Example") If CreatePopupMenu(0) ; here the creating of the pop-up menu begins... MenuTitle("Project") ; you can use any of the menu creating commands, MenuItem(1, "Open") ; just like in a normal menu... MenuItem(2, "Save") MenuItem(3, "Save as") MenuItem(4, "Quit") MenuBar() OpenSubMenu("Recent files") MenuItem(5, "PureBasic.exe") MenuItem(6, "Test.txt") CloseSubMenu() MenuTitle("Edit") MenuTitle("Options") EndIf Repeat Select WaitWindowEvent() ; check for window events Case #WM_RButtonDown ; right mouse button was clicked => DisplayPopupMenu(0, Window(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 : Quit = 1 Case 5 : Debug "Menu: PureBasic.exe" Case 6 : Debug "Menu: Text.txt" EndSelect Case #PB_Event_CloseWindow Quit = 1 EndSelect Until Quit = 1 EndIf
Supported OS
All