How I can do that? For example a dynamic list with the opened files? There is no DeleteMenuItem() function...
Or I have to rebuild the complete popup menu every time before I show it? But how I delete the complete popup menu after disappearing? There is no event for "popup menu is hidden now"
Build a popup-submenu with a variable number of entries?
- RSBasic
- Moderator
- Posts: 1218
- Joined: Thu Dec 31, 2009 11:05 pm
- Location: Gernsbach (Germany)
- Contact:
Re: Build a popup-submenu with a variable number of entries?
Crossplattform resultion: You can recreate your menu:
\\Edit:
If WinAPI: RemoveMenu_()
Code: Select all
EnableExplicit
If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(1, 10, 10, 100, 20, "CHange menu", 0)
If CreatePopupMenu(1)
MenuItem(1, "Hello")
MenuItem(2, "Hi")
MenuItem(3, "Hola")
EndIf
Repeat
Select WaitWindowEvent()
Case #PB_Event_RightClick
DisplayPopupMenu(1, WindowID(0))
Case #PB_Event_Gadget
Select EventGadget()
Case 1
If CreatePopupMenu(1)
MenuItem(1, "Hello")
MenuItem(2, "Hi")
EndIf
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
EndIf
If WinAPI: RemoveMenu_()
- RSBasic
- Moderator
- Posts: 1218
- Joined: Thu Dec 31, 2009 11:05 pm
- Location: Gernsbach (Germany)
- Contact:
Re: Build a popup-submenu with a variable number of entries?
Lebostein wrote:There is no event for "popup menu is hidden now"
Code: Select all
EnableExplicit
Procedure WinCallback(hWnd, uMsg, wParam, lParam)
Select uMsg
Case #WM_UNINITMENUPOPUP
Debug "PopupMenu is now hidden."
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If CreatePopupMenu(1)
MenuItem(1, "Hallo")
MenuItem(2, "Welt")
EndIf
SetWindowCallback(@WinCallback())
Repeat
Select WaitWindowEvent()
Case #PB_Event_RightClick
DisplayPopupMenu(1, WindowID(0))
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
EndIf
Re: Build a popup-submenu with a variable number of entries?
Recreating the menu is the way to go