PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Can you have a single POPUP MENU for all controls on a form?  (Read 202 times)

Mark Strickland

  • Guest
Can you have a single POPUP MENU for all controls on a form?
« on: December 14, 2005, 05:21:47 PM »

I have played some but I can't figure it out.

Is it possible to have a single POPUP menu for a form and I can detect the control where the right mouse button was clicked?  Possibly in the CUSTOM EVENT for the form?  The wParam seems to be the handle of the control where the right click happend in the FORM custom event.  wMsg always seems to be 32 when the mouse is over a control.  Does the RIGHTCLICK get "eaten" by the control RIGHTCLICK FF event?

If you use the RIGHTCLICK event in the form it only fires when you are NOT over a control.

SORRY -- it seems I always want something I don't have.

Thanks.
Logged

TechSupport

  • Guest
Can you have a single POPUP MENU for all controls on a form?
« Reply #1 on: December 14, 2005, 11:49:34 PM »

You can catch most popup menu requests via the CUSTOM handler for the FORM.
Code: [Select]

Function FORM1_CUSTOM ( _
                      hWndForm      As Dword, _  ' handle of Form
                      wMsg          As Long,  _  ' type of message
                      wParam        As Dword, _  ' first message parameter
                      lParam        As Long   _  ' second message parameter
                      ) As Long

   Local xpos As Long
   Local ypos As Long
   
   
   Select Case wMsg
   
     Case %WM_CONTEXTMENU
         ' wParam holds the hwnd of the button/form that the mouse is over.
         xpos = LoWrd(lParam)
         ypos = HiWrd(lParam)
         MsgBox "Right button was clicked on hwnd=" & Str$(wParam) & " at" & Str$(xpos) & "," & Str$(ypos)
   
   End Select
   
End Function


You need to deal with the right click popup menus that are automatically generated by TextBoxes. Notice that the sample below returns TRUE from the function in order to cancel the default popup menu.
Code: [Select]

Function FORM1_TEXTBOX1_CUSTOM ( _
                                 ControlIndex  As Long,  _  ' index in Control Array
                                 hWndForm      As Dword, _  ' handle of Form
                                 hWndControl   As Dword, _  ' handle of Control
                                 wMsg          As Long,  _  ' type of message
                                 wParam        As Dword, _  ' first message parameter
                                 lParam        As Long   _  ' second message parameter
                                 ) As Long
   Local xpos As Long
   Local ypos As Long

   Select Case wMsg
   
     Case %WM_CONTEXTMENU
         ' wParam holds the hwnd of the button/form that the mouse is over.
         xpos = LoWrd(lParam)
         ypos = HiWrd(lParam)
         MsgBox "Right button was clicked on hwnd=" & Str$(wParam) & " at" & Str$(xpos) & "," & Str$(ypos)
         Function = %TRUE
         
   End Select

End Function
Logged