这里有个例子,是一般方法:'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
'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
解决方案 »
- vb外挂HOOK技术,详细的解说,呕心沥血。只为人气
- 100分的大问题~~!
- 如何在datareport中使针式打印机自动回纸.(解决者给500分)
- VB中的延时的函是什么?
- EXCEL如何制作弹出选择框?
- 在VB中用USE命令
- VB对access数据库查询,但是数据库太大,20万条左右的数据
- 调用dll时会用到很多windows自定义的常量,哪里有他们的详细介绍?
- 我想做一个标准按钮栏,拜托哪位高手发一套标准图标给我啊,就是新建、保存那样的图标~~
- 怎样用带索引的方法(SQL)打开没有索引的Access文件?
- 如何获取插入光标所在的屏幕坐标?
- 我——一个只会用VB(而且还用得不好)的菜鸟,因为看AdamBear的《VB到底为我们做了什么?》看傻掉了,所以郑重决定闭门深造。请各位指路
[email protected]
指装有图标的图片框。如果闲麻烦,把picture1/2换成me也可以(Me.Icon)
你可以用Imagelist控件中将所有的Bmp(而不是其客它类型)装入。
注意,
不要给菜单分割条加图片即不会出错。
'取得程序中 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,在里面放个图。
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代码怎么写?