| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1048 人关注过本帖
标题:点击鼠标右键如何弹出有图标的菜单?
只看楼主 加入收藏
jrs123
Rank: 2
等 级:论坛游民
威 望:1
帖 子:627
专家分:14
注 册:2006-9-5
结帖率:94.12%
收藏
 问题点数:0 回复次数:1 
点击鼠标右键如何弹出有图标的菜单?
下面是一段右击鼠标弹出有图标菜单的代码,但当菜单处于"不可见"时,菜单栏无法显示图标?(详见附件)
请问在菜单栏不显示状态,如何才能实现"点击鼠标右键如何弹出有图标的一二级菜单",下面代码错在何处?(最好在附件上改)
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)
搜索更多相关主题的帖子: 菜单 鼠标 图标 
2008-10-25 08:07
三断笛
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:31
帖 子:1621
专家分:1617
注 册:2007-5-24
收藏
得分:0 
不错,顶顶!
2008-10-25 11:53
快速回复:点击鼠标右键如何弹出有图标的菜单?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.057872 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved