VB给系统菜单加上图标
求图标怎么用VB加
追问:ImageList什么控件啊 有图吗
求图标怎么用VB加
追问:ImageList什么控件啊 有图吗
答案:vb本身没法解决,得借助api函数
'API函数声明
Option Explicit
Private Declare Function GetMenu Lib "user32 " (ByVal hwnd As Long) _
As Long '取得窗口的菜单句柄,hwnd是窗口的句柄
Private Declare Function GetSubMenu Lib "user32 " (ByVal hMenu As _
Long, ByVal nPos As Long) As Long '取得子菜单句柄,nPos是菜单的位置
Private Declare Function SetMenuItemBitmaps Lib "user32 " (ByVal _
hMenu As Long, ByVal nPos As Long, ByVal wFlags As Long, ByVal _
hBitUnchecked As Long, ByVal hBitChecked As Long) As Long
'为菜单设置相应的图形
Const MF_BITMAP = &H400&
'用image或picture或imagelist控件装入图形(必须是bmp格式),16*16左右
'建好菜单
Private Sub Form_Load()
Dim hMenu, hSubMenu1, hSubMenu2 As Long
hMenu = GetMenu(Me.hwnd)
hSubMenu1 = GetSubMenu(hMenu, 0) '取得第一项菜单的子菜单句柄
SetMenuItemBitmaps hSubMenu1, 0, MF_BITMAP, imagelist1.listimages(1) _
.Picture, imagelist1.listimages(1).Picture
'为hSubMenu1的第一项设置图形,假设用imagelist控件装入图形
SetMenuItemBitmaps hSubMenu1, 1, MF_BITMAP, imagelist1.listimages(2) _
.Picture, imagelist1.listimages(2).Picture
'设置第二项,同样你还可以设置第xx项。
hSubMenu2 = GetSubMenu(hMenu, 1) '取得第二项菜单的子菜单句柄
'也可用SetMenuItemBitmaps来设置它的图形,只更改hSubMenu1为hSubMenu2
'即可
End Sub
上一个:一个vb程序的问题
下一个:vb程序右键打开文件的问题。