• Welcome to PlanetSquires Forums.
 

Can you have a single POPUP MENU for all controls on a form?

Started by Mark Strickland, December 14, 2005, 05:21:47 PM

Previous topic - Next topic

Mark Strickland

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.

TechSupport

You can catch most popup menu requests via the CUSTOM handler for the FORM.

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.

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