点击鼠标右键如何弹出有图标的菜单?
下面是一段右击鼠标弹出有图标菜单的代码,但当菜单处于"不可见"时,菜单栏无法显示图标?(详见附件)请问在菜单栏不显示状态,如何才能实现"点击鼠标右键如何弹出有图标的一二级菜单",下面代码错在何处?(最好在附件上改)
Option Explicit
Private Declare Function GetMenu Lib "user32" _
(ByVal hwnd 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
Const MF_BYPOSITION = &H400&
Private Sub Form_Load()
Dim mHandle As Long, lRet As Long, sHandle As Long, sHandle2 As Long
mHandle = GetMenu(hwnd)
sHandle = GetSubMenu(mHandle, 0)
lRet = SetMenuItemBitmaps(sHandle, 0, MF_BYPOSITION, jrstp1.Picture, jrstp1.Picture)
lRet = SetMenuItemBitmaps(sHandle, 1, MF_BYPOSITION, jrstp2.Picture, jrstp2.Picture)
lRet = SetMenuItemBitmaps(sHandle, 2, MF_BYPOSITION, jrstp3.Picture, jrstp3.Picture)
lRet = SetMenuItemBitmaps(sHandle, 3, MF_BYPOSITION, jrstp4.Picture, jrstp4.Picture)
lRet = SetMenuItemBitmaps(sHandle, 4, MF_BYPOSITION, jrstp5.Picture, jrstp5.Picture)
lRet = SetMenuItemBitmaps(sHandle, 5, MF_BYPOSITION, jrstp6.Picture, jrstp6.Picture)
lRet = SetMenuItemBitmaps(sHandle, 6, MF_BYPOSITION, jrstp7.Picture, jrstp7.Picture)
lRet = SetMenuItemBitmaps(sHandle, 7, MF_BYPOSITION, jrstp8.Picture, jrstp8.Picture)
lRet = SetMenuItemBitmaps(sHandle, 8, MF_BYPOSITION, jrstp9.Picture, jrstp9.Picture)
End Sub
Private Sub frame1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button And vbRightButton Then
PopupMenu jrswj
End If
End Sub
Private Sub tp8_Click()
End
End Sub
右击鼠标弹出带图标的菜单.rar
(8.32 KB)