John Peter
New Member
- Joined
- Apr 30, 2022
- Messages
- 10
- Office Version
- 365
- Platform
- Windows
VBA Code:
Private Declare PtrSafe Function DestroyMenu Lib "user32" (ByVal hMenu As Long) As Long
Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare PtrSafe Function CreatePopupMenu Lib "user32" () As Long
Private Declare PtrSafe Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
Private Declare PtrSafe Function SetMenu Lib "user32" (ByVal hWnd As LongPtr, ByVal hMenu As LongPtr) As Long
Private Declare PtrSafe Function CreateMenu Lib "user32" () As Long
Private Declare PtrSafe Function AppendMenu Lib "user32" Alias "AppendMenuA" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As Any) As Long
Const MF_STRING = &H0&: Const MF_POPUP = &H10&
Const MF_SEPARATOR = &H800&: Const MF_GRAYED = &H1&
Dim hMenu, hMenu2, hMenu3, hMenu4 As Long
Dim hWnd As Long
Private Sub UserForm_Initialize()
hWnd = FindWindow(vbNullString, Me.Caption)
hMenu2 = CreatePopupMenu()
hMenu3 = CreatePopupMenu()
hMenu4 = CreatePopupMenu()
hMenu = CreateMenu()
SetMenu hWnd, hMenu
AppendMenu hMenu, MF_POPUP, hMenu2, "More"
AppendMenu hMenu2, MF_POPUP, 1, "Cut"
AppendMenu hMenu2, MF_STRING, 2, "set"
AppendMenu hMenu2, MF_STRING, 3, " Pdf"
AppendMenu hMenu, MF_POPUP, hMenu3, "More"
AppendMenu hMenu3, MF_STRING, 1, "Reset"
AppendMenu hMenu3, MF_STRING, 11, "Op"
AppendMenu hMenu3, MF_STRING, 4, "Paste"
AppendMenu hMenu, MF_POPUP, hMenu4, "More2"
AppendMenu hMenu4, MF_STRING, 3, "Reset"
AppendMenu hMenu4, MF_STRING, 11, "Open"
AppendMenu hMenu4, MF_SEPARATOR, 333, ByVal 0&
AppendMenu hMenu4, MF_STRING, 3, "Reopen"
AppendMenu hMenu4, MF_STRING, 11, "Open Pdf"
DrawMenuBar hWnd
End Sub