- 生肖
- 蛇
- 星座
- 狮子座
- 性别
- 男
- 积分
- 0
- 积分
- 104
- 精华
- 1
- 阅读权限
- 100
- 注册时间
- 2013-11-3
- 最后登录
- 2014-4-4
- 帖子
- 27
- 生肖
- 蛇
- 星座
- 狮子座
- 性别
- 男
|
为保证读者顺利上机实践,请遵照下面的每一个步骤
(1)建立一个菜单(如果不清楚菜单编辑器的使用,请百度),层次结构如下图:
(2)添加一个IimageList控件,并添加至少四张图片(不会添加的请百度,此处不赘述),效果如图2
(3)引用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 GetMenuItemID 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
Const MF_bitmap = &H4&
(4)添加Form_Load事件代码
Private Sub Form_Load()
'为“进货管理”菜单下的子菜单添加图标
Dim i As Integer
Dim menu1 As Long
Dim menuID As Long
menu1 = GetMenu(Me.hwnd)
For i = 1 To 4
menuID = GetMenuItemID(GetSubMenu(menu1, 0), i - 1)
SetMenuItemBitmaps menu1, menuID, MF_bitmap, ImageList2.ListImages(i).Picture, ImageList2.ListImages(i).Picture
Next
End Sub
|
|