definde function 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
Now we can add icon to menu.
'ÃÃÃæÃóÃÃò¿ªÃ¼¡£
Dim sHandle As Long, mHandle As Long
mHandle = GetMenu(frm.hwnd) 'get handle of the menu
sHandle = GetSubMenu(mHandle, 0) 'get handle of submenu
SetMenuItemBitmaps sHandle, 0, &H400&, img.ListImages(1).Picture, img.ListImages(1).Picture
'add icon
'we add an icon to menu from imglist,well you can add icon from picturebox or imagebox.
|