📄 menubmp.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "将图标放置到菜单栏"
ClientHeight = 1860
ClientLeft = 1140
ClientTop = 1800
ClientWidth = 4605
LinkTopic = "Form1"
PaletteMode = 1 'UseZOrder
ScaleHeight = 1860
ScaleWidth = 4605
Begin VB.Image imCopy
Height = 195
Left = 3600
Picture = "menubmp.frx":0000
Top = 600
Visible = 0 'False
Width = 225
End
Begin VB.Image imPrintSetup
Height = 225
Left = 3000
Picture = "menubmp.frx":0512
Top = 600
Visible = 0 'False
Width = 180
End
Begin VB.Image imPrint
Height = 210
Left = 2280
Picture = "menubmp.frx":0A08
Top = 600
Visible = 0 'False
Width = 240
End
Begin VB.Image imSave
Height = 210
Left = 1680
Picture = "menubmp.frx":0F2A
Top = 600
Visible = 0 'False
Width = 210
End
Begin VB.Image imOpen
Height = 195
Left = 1080
Picture = "menubmp.frx":144C
Top = 600
Visible = 0 'False
Width = 240
End
Begin VB.Menu mnuFile
Caption = "文件"
Begin VB.Menu mnuOpen
Caption = "&Open"
End
Begin VB.Menu mnuSave
Caption = "&Save"
End
Begin VB.Menu Sep1
Caption = "-"
End
Begin VB.Menu mnuPrint
Caption = "&Print"
End
Begin VB.Menu mnuPrintSetup
Caption = "Print &Setup"
End
End
Begin VB.Menu mnuEdit
Caption = "编辑"
Begin VB.Menu mnuExtra
Caption = "二级菜单"
Begin VB.Menu mnuCopy
Caption = "复制"
End
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
' MenuBmp sample by Matt Hart - mhart@taascforce.com
' http://www.webczar.com/defcon/mh/vbhelp.html
' http://www.webczar.com/defcon/mh
'
' This sample shows you how to add bitmaps to your
' menu items. First, you must retrieve the VB menu handle
' with the GetMenu API call. Then, you set the Unchecked and
' Checked bitmaps (I don't differentiate between the two
' with this example - usually you would put a checkmark in
' the bitmap and use that for Checked).
'
' Note that the Picture property of an Image control (or
' a Picture control) is the Bitmap Handle, this the Image
' controls can be used like a bitmap resource.
'
' I also have one sub menu so that you can see how getting
' submenu handles and item positions works.
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
Const MF_BYPOSITION = &H400&
' VB 5 doesn't need this declration, but VB 4 does.
' Private Declare Function VarPtr Lib "VB40032.DLL" (variable As Any) As Long
Private Sub Form_Load()
Dim mHandle As Long, lRet As Long, sHandle As Long, sHandle2 As Long
mHandle = GetMenu(hwnd)
sHandle = GetSubMenu(mHandle, 0)
lRet = SetMenuItemBitmaps(sHandle, 0, MF_BYPOSITION, imOpen.Picture, imOpen.Picture)
lRet = SetMenuItemBitmaps(sHandle, 1, MF_BYPOSITION, imSave.Picture, imSave.Picture)
lRet = SetMenuItemBitmaps(sHandle, 3, MF_BYPOSITION, imPrint.Picture, imPrint.Picture)
lRet = SetMenuItemBitmaps(sHandle, 4, MF_BYPOSITION, imPrintSetup.Picture, imPrintSetup.Picture)
sHandle = GetSubMenu(mHandle, 1)
sHandle2 = GetSubMenu(sHandle, 0)
lRet = SetMenuItemBitmaps(sHandle2, 0, MF_BYPOSITION, imCopy.Picture, imCopy.Picture)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -