PopupMenu and StatuBar
Posted: Sun Apr 14, 2013 9:28 am
Hello, does anyone know if you can see a Popupmenu clicking on Statubar?
Hello everyone and happy Sunday ...
Hello everyone and happy Sunday ...
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
EnableExplicit ; Optional - Recommended
Global Window_0,Event
Procedure Menu() ; create menu
If CreatePopupMenu(1) ; creation of the pop-up menu begins...
MenuItem(1, "Help Topics")
MenuItem(2, "About")
EndIf
EndProcedure
Procedure MyWindowCallback(WindowID, Message, wParam, lParam)
Protected Result,wParamLo = wParam & $FFFF, lParamLo = lParam & $FFFF
Result = #PB_ProcessPureBasicEvents
If Message = 528 ; StatusbarFocus
If wParamLo = 516 And lParamLo > 50+2 ; 516 = Right click - lParamLo = position
DisplayPopupMenu(1, WindowID(Window_0)) ;note: use x and y to create better locations for the popup menu
EndIf
EndIf
ProcedureReturn Result
EndProcedure
Procedure OpenWindow_0()
Window_0 = OpenWindow(#PB_Any, 0, 0, 600, 400, "Menu From Status Bar", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CreateStatusBar(0, WindowID(Window_0))
AddStatusBarField(50)
StatusBarText(0, 0, "")
AddStatusBarField(200)
StatusBarText(0, 1, "Right Click For Help")
EndProcedure
OpenWindow_0() ; Call procedure to open window with status bar, etc
Menu() ; create popup
SetWindowCallback(@MyWindowCallback()) ; set callback
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow ; Quit on any window close
Code: Select all
OpenWindow(0, 0, 0, 600, 400, "Menu From Status Bar", #PB_Window_SystemMenu |#PB_Window_SizeGadget| #PB_Window_ScreenCentered)
CreateStatusBar(0, WindowID(0))
AddStatusBarField(50)
StatusBarText(0, 0, "File")
AddStatusBarField(50)
StatusBarText(0, 1, "Help")
CreatePopupMenu(1)
MenuItem(1, "Help Topics")
MenuItem(2, "About")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #WM_RBUTTONDOWN
GetCursorPos_(p.POINT)
GetWindowRect_(StatusBarID(0),r.RECT)
If PtInRect_(r,p\y<<32+p\x)
DisplayPopupMenu(1,WindowID(0))
EndIf
EndSelect
Until Quit = 1
End