这里有个例子,是一般方法:'This project needs a form with a menu with at least one submenu
'It also needs a picturebox, Picture1, that contains a small b/w bitmap
Const MF_BYPOSITION = &H400&
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
Private Sub Form_Load()
    'KPD-Team 2000
    'URL: [email protected]
    'E-Mail: [email protected]
    Dim hMenu As Long, hSubMenu As Long
    'get the handle of the menu
    hMenu = GetMenu(Me.hwnd)
    'check if there's a menu
    If hMenu = 0 Then
        MsgBox "This form doesn't have a menu!"
        Exit Sub
    End If
    'get the first submenu
    hSubMenu = GetSubMenu(hMenu, 0)
    'check if there's a submenu
    If hSubMenu = 0 Then
        MsgBox "This form doesn't have a submenu!"
        Exit Sub
    End If
    'set the menu bitmap
    SetMenuItemBitmaps hSubMenu, 0, MF_BYPOSITION, Picture1.Picture, Picture1.Picture
End Sub

解决方案 »

  1.   

    试过了,但是不行,最后第二句的两个PICTURE指的是什么?
      

  2.   

    从Project菜单,选Components,从控件列表选择Microsoft Windows Common Controls 6.0,里面有图片的属性,先看看吧
      

  3.   

    我有这方面的控件。
    [email protected]
      

  4.   

    TO raymond2088(头大)
    指装有图标的图片框。如果闲麻烦,把picture1/2换成me也可以(Me.Icon)
      

  5.   

    老大,求求您,您看看MSDN吧。
      

  6.   

    这个方法是对的。
    你可以用Imagelist控件中将所有的Bmp(而不是其客它类型)装入。
    注意,
    不要给菜单分割条加图片即不会出错。
      

  7.   

    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 SetMenuItemBitmaps Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal hBitmapUnchecked As Long, ByVal hBitmapChecked As Long) As LongPrivate Sub Form_Load()
    '取得程序中 Mennu 的 handle
    hMenu = GetMenu(Form1.hwnd)
    '取得第一个 submenu 的 handle
    hSubMenu = GetSubMenu(hMenu, 0)
    '加入图片
    SetMenuItemBitmaps hSubMenu, 0, MF_BYPOSITION, Picture1.Picture, Picture1.Picture '先取子菜单,“0”为子菜单项,Picture1.Picture是说,你需要先加个PictureBox,在里面放个图。
      

  8.   

    Const MF_BYPOSITION = &H400&
    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 LongPrivate Sub Form_Load()Dim hMenu As Long, hSubMenu As LonghMenu = GetMenu(Me.hwnd)If hMenu = 0 Then
    MsgBox "This form doesn't have a menu!"
    Exit Sub
    End If
    hSubMenu = GetSubMenu(hMenu, 0)
    If hSubMenu = 0 Then
    MsgBox "This form doesn't have a submenu!"
    Exit Sub
    End If
    SetMenuItemBitmaps hSubMenu, 1, MF_BYPOSITION, Picture1.Picture, Picture1.Picture
    End Sub这是代码,我用的是PICTUREBOX,用IMAGELIST代码怎么写?