image控件没法添加上去啊

解决方案 »

  1.   

    不用image控件一样可以做图形菜单
      

  2.   

    填加image控键,在属性中插入图片后写入如下代码:
    Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As LongPrivate Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, _
        ByVal nPos As Long) As LongPrivate Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, _
        ByVal nPos As Long) As LongPrivate 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 LongConst MF_bitmap = &H4&----------------------------------------------------------------------
    Private Sub MDIForm_Load()  Dim i As Integer
      Dim menu1 As Long
      Dim menuID As Long
      menu1 = GetMenu(Me.hwnd)              
      For i = 1 To 3                        '插入了3幅图片
        menuID = GetMenuItemID(GetSubMenu(menu1, 0), i - 1)
        SetMenuItemBitmaps menu1, menuID, MF_bitmap, ImageList1.ListImages(i).Picture, _
                           ImageList1.ListImages(i).Picture
      NextEnd Sub
    成功执行,有问题问我!
      

  3.   

    lanhai96(蓝海)  说的对,任何菜单里面添加图片只是通过API将图形内容绑定到指定菜单上,先弄清楚原理再想办法解决,可别再想通过控件去实现了,VB确实可以实现,不过累不死你也差不多了!
    遇到难题的时候就直接去查API就可以了,99.9%的难题都是通过API解决的
      

  4.   

    Dim hMenu As Long, hSubMenu As Long
    Dim RetVal As Long
        hMenu = GetMenu(Me.hwnd)
        hSubMenu = GetSubMenu(hMenu, 0) '第一栏
        RetVal = SetMenuItemBitmaps(hSubMenu, 0, MF_BYPOSITION, ImageList2.ListImages(1).Picture, ImageList2.ListImages(1).Picture)
        RetVal = SetMenuItemBitmaps(hSubMenu, 1, MF_BYPOSITION, ImageList2.ListImages(2).Picture, ImageList2.ListImages(2).Picture)
        RetVal = SetMenuItemBitmaps(hSubMenu, 2, MF_BYPOSITION, ImageList2.ListImages(3).Picture, ImageList2.ListImages(3).Picture)
    这样为什么只有第一个有图标,我加了3个的
      

  5.   

    //这样为什么只有第一个有图标,我加了3个的程序没有问题,看看你的ImageList2控件里有没有图标存在,或者换一种文件格式(建议全部换成bmp文件,当为其它格式的时候,ImageList2.ListImages(1).Picture指向的不一定是bitmap)