用户登录  |  用户注册
首 页商业源码原创产品编程论坛
当前位置:PB创新网文章中心编程技巧VisualBasic

在菜单上增加图标

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2009-03-16 19:48:50
声明:
Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
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
Public Const MF_BITMAP = &H4&
Type MENUITEMINFO
cbSize As Long
fMask As Long
fType As Long
fState As Long
wID As Long
hSubMenu As Long
hbmpChecked As Long
hbmpUnchecked As Long
dwItemData As Long
dwTypeData As String
cch As Long
End Type
Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Declare Function GetMenuItemInfo Lib "user32" Alias "GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal b As Boolean, lpMenuItemInfo As MENUITEMINFO) As Boolean
Public Const MIIM_ID = &H2
Public Const MIIM_TYPE = &H10
Public Const MFT_STRING = &H0&


使用: 在 Form1 中增加一个 PictureBox1, AutoSize 为 True, 放一个小 Bmp (不是 Icon!推荐 13*13)。
Private Sub Command1_Click()

''Get the menuhandle of your app
hMenu& = GetMenu(Form1.hwnd)

''Get the handle of the first submenu (Hello)
hSubMenu& = GetSubMenu(hMenu&, 0)

''Get the menuId of the first entry (Bitmap)
hID& = GetMenuItemID(hSubMenu&, 0)

''Add the bitmap
SetMenuItemBitmaps hMenu&, hID&, MF_BITMAP, Picture1.Picture, Picture1.Picture
''You can add two bitmaps to a menuentry
''One for the checked and one for the unchecked
''state.

End Sub

Tags:

作者:佚名

文章评论评论内容只代表网友观点,与本站立场无关!

   评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论

相关文章

PB创新网ourmis.com】Copyright © 2000-2009 . All Rights Reserved .
页面执行时间:9,921.87500 毫秒
Email:ourmis@126.com QQ:2322888 蜀ICP备05006790号