Option ExplicitPublic Declare Function GetMenu Lib "user32" (ByVal hWnd As Long) As LongPublic Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As LongPublic Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As LongPublic 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'设置菜单图片
Sub Menu_Icon(Fn As Form, MainIndex As Integer, SubIndex As Integer, Pn As String)
'Fn:用于哪个Form上
'MainIndex:从左边开始,第几个主菜单,下标0
'SubIndex:从上开始,第几个子菜单,下标0
'Pn:ImageList中的图片的名称Dim i%
Dim hMenu, hSubMenu, MenuId, x
With FnhMenu = GetMenu(.hWnd)
hSubMenu = GetSubMenu(hMenu, MainIndex) '1 for "Other" menu etceteraMenuId = GetMenuItemID(hSubMenu, SubIndex)
x = SetMenuItemBitmaps(hMenu, MenuId, &H4, .Imag.ListImages(Pn).Picture, .Imag.ListImages(Pn).Picture)
End With
End Sub

解决方案 »

  1.   

    楼上的myhfit()
    可否祥细一些!具体该怎么做啊!
      

  2.   

    ListImages中的图片13*13,否则显示出来的图片好看
      

  3.   

    yefm(百聊)
    你好!
    好像无法显示图标,可能你给的这段子程续哪里还有问题吧!
      

  4.   

    Option Explicit
    '定义API函数
    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 myflag = &H400&Private Sub cmd1_Click()
       MsgBox "你好!", 128, "问好"
    End SubPrivate Sub cmd2_Click()
      End
    End SubPrivate Sub Form_Load()
      Dim mHandle As Long, lRet As Long, sHandle As Long
      mHandle = GetMenu(hwnd)  '获得菜单的句柄
      sHandle = GetSubMenu(mHandle, 0) '获得菜单子菜单第一个单项的句柄
      lRet = SetMenuItemBitmaps(sHandle, 0, myflag, imgNew.Picture, imgNew.Picture)  '为子菜单设置图形
      lRet = SetMenuItemBitmaps(sHandle, 1, myflag, imgOpen.Picture, imgOpen.Picture)
      lRet = SetMenuItemBitmaps(sHandle, 2, myflag, imgSave.Picture, imgSave.Picture)
      sHandle = GetSubMenu(mHandle, 1)
      lRet = SetMenuItemBitmaps(sHandle, 0, myflag, imgCopy.Picture, imgCopy.Picture)
      lRet = SetMenuItemBitmaps(sHandle, 1, myflag, imgCut.Picture, imgCut.Picture)
      lRet = SetMenuItemBitmaps(sHandle, 2, myflag, imgPaste.Picture, imgPaste.Picture)
    End Sub
      

  5.   

    非常感谢 michen(感觉太好)
    但这样行是行,只是能附合要求的图标太少了,我要么得用专用图标制作工具进行修改,要么只能用一些不怎么好看的图标,我用Imagelist控件替换掉了image控件,设为10x10,可显示效果还是16x16的,不知该怎么办?可能还得加上一些API函数吧!
      

  6.   

    图标工具:http://yoya2000.myetang.com/zbx/index.htm
      

  7.   

    MF_BITMAP格式就是只能是位图
    用SetMenuItemBitmaps加的“图标”最好是 13*13的单色(1位色)位图,因为Windows是以And方式绘制的要实现漂亮的菜单效果,使用自绘菜单技术:
    http://cocgame.myetang.com/zyl910/gui/drawmenu-s.zip