PopupMenu and StatuBar

Just starting out? Need help? Post your questions and find answers here.
alver
User
User
Posts: 21
Joined: Mon Aug 03, 2009 8:38 am
Location: Italy

PopupMenu and StatuBar

Post by alver »

Hello, does anyone know if you can see a Popupmenu clicking on Statubar?
Hello everyone and happy Sunday ...
rrpl
Enthusiast
Enthusiast
Posts: 121
Joined: Fri Apr 18, 2008 7:22 am
Location: Australia

Re: PopupMenu and StatuBar

Post 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.
"What you are is what you have been. What you’ll be is what you do now.” -Buddha
alver
User
User
Posts: 21
Joined: Mon Aug 03, 2009 8:38 am
Location: Italy

Re: PopupMenu and StatuBar

Post 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
rrpl
Enthusiast
Enthusiast
Posts: 121
Joined: Fri Apr 18, 2008 7:22 am
Location: Australia

Re: PopupMenu and StatuBar

Post 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
"What you are is what you have been. What you’ll be is what you do now.” -Buddha
alver
User
User
Posts: 21
Joined: Mon Aug 03, 2009 8:38 am
Location: Italy

Re: PopupMenu and StatuBar

Post 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
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: PopupMenu and StatuBar

Post 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
Egypt my love
alver
User
User
Posts: 21
Joined: Mon Aug 03, 2009 8:38 am
Location: Italy

Re: PopupMenu and StatuBar

Post by alver »

I owe you a beer for your trouble ... Hello
Post Reply