Microsoft Office Tutorials and References
In Depth Information
ADD A RIGHT-CLICK MENU TO A USER FORM
Private Declare Function AppendMenu Lib "user32" Alias "AppendMenuA"
_
(ByVal hMenu As Long, ByVal wFlags As Long, ByVal wIDNewItem
As Long, _
ByVal lpNewItem As Any) As Long
Private Declare Function DestroyMenu Lib "user32" (ByVal hMenu As
Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As
POINTAPI) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"
_
(ByVal lpClassName As String, ByVal lpWindowName As String)
As Long
Const MF_CHECKED = &H8&
Const MF_APPEND = &H100&
Const TPM_LEFTALIGN = &H0&
Const MF_SEPARATOR = &H800&
Const MF_STRING = &H0&
Const TPM_RETURNCMD = &H100&
Const TPM_RIGHTBUTTON = &H2&
Dim hMenu As Long
Dim hWnd As Long
Private Sub UserForm_Initialize()
hWnd = FindWindow(vbNullString, Me.Caption)
End Sub
Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift
As Integer, ByVal X As Single, ByVal Y As Single)
Dim Pt As POINTAPI
Dim ret As Long
If Button = 2 Then
hMenu = CreatePopupMenu()
AppendMenu hMenu, MF_STRING, 1, "Menu Item 1"
 
Search JabSto ::




Custom Search