These give a sample for a generic popup edit menu which can be called from any text box within an app. The key here is that it makes sure the object you want the pop-up menu for has the focus.
Declare Function GetFocus% Lib "user" ()
Sub Text1_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
' Focus might not be on this control, even though it has trapped
' the right mouse button.
' We use the API call GetFocus to check for this
Dim Res%
Res = GetFocus()
' If it is the right mouse button
If Button = 2 Then
' If Text1 has the focus
If Res = Text1.hWnd Then
' Show menu
PopupMenu Form2!mnuEdit
End If
End If
End Sub
|