Page 1 of 1

PopupMenu and StatuBar

Posted: Sun Apr 14, 2013 9:28 am
by alver
Hello, does anyone know if you can see a Popupmenu clicking on Statubar?
Hello everyone and happy Sunday ...

Re: PopupMenu and StatuBar

Posted: Sun Apr 14, 2013 10:47 am
by rrpl
Yes you can trigger a popup menu from a status bar.
Have a look at the windows callback used in the purebasic code archive V4: - a file called "statusbar_events.pb" or the file "menuhelp_in_statusbar.pb". The basic principles in these examples will work once updated and adapted to your needs.
If you still need further help please provide some same code of what you are trying to do.

Re: PopupMenu and StatuBar

Posted: Sun Apr 14, 2013 11:25 am
by alver
Thanks a lot rrpl, in fact I've already tried as you suggested, but it seems not to work the DisplayPopuMenu ()

Procedure MyWindowCallback(WindowID, Message, wParam, lParam)

Result = #PB_ProcessPureBasicEvents

wParamLo = wParam & $FFFF
lParamLo = lParam & $FFFF

If Message = 528 ; StatusbarFocus
If wParamLo = 516 And lParamLo > 502 And lParamLo < 750 ; 516 = Right click - lParamLo = position
DisplayPopupMenu(#POPMENU_NCS, WindowID(#WND_MAIN))
EndIf
EndIf

ProcedureReturn Result

EndProcedure

Re: PopupMenu and StatuBar

Posted: Sun Apr 14, 2013 11:58 am
by rrpl
Yeah it does, but can't tell you where you when wrong without the other code.
Quickly made some up just to test, see below (note: right mouse click on help);

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

Re: PopupMenu and StatuBar

Posted: Sun Apr 14, 2013 1:02 pm
by alver
rrpl, thanks for the answers. I have to figure out where is the hitch, because the code that I use is pretty much like what I've posted you.
If I find the mistake I'll let you know so you will help me to give me an idiot.
Hello and good day

Re: PopupMenu and StatuBar

Posted: Sun Apr 14, 2013 1:32 pm
by RASHAD
Simple one

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

Re: PopupMenu and StatuBar

Posted: Sun Apr 14, 2013 2:06 pm
by alver
I owe you a beer for your trouble ... Hello