- 关 键 词:
- combo
1. 放一个 ComboBox 到表单.
2. 放一个 Toolbar 在表单.
3. 增加下面的代码到 Form1 :
Private Sub Form_Load()
Dim btn As Button
Me.Show
Set btn = Toolbar1.Buttons.Add()
btn.Style = tbrSeparator
Set btn = Toolbar1.Buttons.Add()
btn.Style = tbrPlaceholder
btn.Key = "ComboBox"
btn.Width = 2000
With Combo1
.ZOrder 0
.Width = Toolbar1.Buttons("ComboBox").Width
.Top = Toolbar1.Buttons("ComboBox").Top
.Left = Toolbar1.Buttons("ComboBox").Left
End With
End Sub
在菜单上增加图标
声明:
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收藏 http://www.qqread.com/vb/b232151.html进入讨论组讨论。
相关专题
- VB+Access设计图书管理系统 (104238次浏览)
- VB设计有语音报时和报警功能的闹钟 (13528次浏览)
- 用VB打造“超酷”个性化菜单 (667次浏览)
- VB基础学习:编码规范 (654次浏览)
- 对注册表进行编程的“捷径” (646次浏览)
- 在IIS中建立WEB站点的例子! (603次浏览)
- 用VB6.0设计简易赛车游戏 (414次浏览)
- 导入注册表设置 (308次浏览)
- 用Visual Basic.NET编写扑克牌游戏 (189次浏览)
- VB急速密码生成---RndString (188次浏览)



