使用win32API
Option Explicit
Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function SetMenuItemBitmaps Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal hBitmapUnchecked As Long, ByVal hBitmapChecked As Long) As Long
Private Const MF_BITMAP = &H4&
Private Const MF_BYPOSITION = &H400&
Private Sub Form_Load()
Dim hMenu As Long, hSubMenu As Long
Dim ret As Long
hMenu = GetMenu(Me.hwnd)
hSubMenu = GetSubMenu(hMenu, 0)
ret = SetMenuItemBitmaps(hSubMenu, 0, MF_BYPOSITION, Picture1.Picture, Picture1.Picture)
ret = SetMenuItemBitmaps(hSubMenu, 1, MF_BYPOSITION, Picture2.Picture, Picture2.Picture)
ret = SetMenuItemBitmaps(hSubMenu, 2, MF_BYPOSITION, Picture3.Picture, Picture3.Picture)
ret = SetMenuItemBitmaps(hSubMenu, 3, MF_BYPOSITION, Picture4.Picture, Picture4.Picture)
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
PopupMenu mnuFile
End If
End Sub