?? form1.frm
字號:
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Begin VB.Form Form1
Caption = "平面工具欄演示的例子"
ClientHeight = 5730
ClientLeft = 165
ClientTop = 735
ClientWidth = 6885
LinkTopic = "Form1"
ScaleHeight = 5730
ScaleWidth = 6885
StartUpPosition = 3 'Windows Default
Begin ComctlLib.Toolbar Toolbar1
Align = 1 'Align Top
Height = 855
Left = 0
TabIndex = 0
Top = 0
Width = 6885
_ExtentX = 12144
_ExtentY = 1508
ButtonWidth = 1032
ButtonHeight = 1349
Appearance = 1
ImageList = "ImageList1"
_Version = 327682
BeginProperty Buttons {0713E452-850A-101B-AFC0-4210102A8DA7}
NumButtons = 10
BeginProperty Button1 {0713F354-850A-101B-AFC0-4210102A8DA7}
Caption = "111"
Description = "111"
Object.Tag = ""
Style = 3
MixedState = -1 'True
EndProperty
BeginProperty Button2 {0713F354-850A-101B-AFC0-4210102A8DA7}
Caption = "222"
Description = "222"
Object.Tag = ""
Style = 3
MixedState = -1 'True
EndProperty
BeginProperty Button3 {0713F354-850A-101B-AFC0-4210102A8DA7}
Caption = "新建"
Description = "3232"
Object.ToolTipText = "新建"
Object.Tag = "222"
ImageIndex = 1
EndProperty
BeginProperty Button4 {0713F354-850A-101B-AFC0-4210102A8DA7}
Caption = "打開"
Description = "2w231"
Object.ToolTipText = "打開"
Object.Tag = "222"
ImageIndex = 2
EndProperty
BeginProperty Button5 {0713F354-850A-101B-AFC0-4210102A8DA7}
Caption = "保存"
Description = "2332"
Object.ToolTipText = "保存"
Object.Tag = ""
ImageIndex = 3
EndProperty
BeginProperty Button6 {0713F354-850A-101B-AFC0-4210102A8DA7}
Caption = "查找"
Description = "3232"
Object.ToolTipText = "查找"
Object.Tag = ""
ImageIndex = 4
EndProperty
BeginProperty Button7 {0713F354-850A-101B-AFC0-4210102A8DA7}
Caption = "333"
Object.Tag = ""
Style = 3
MixedState = -1 'True
EndProperty
BeginProperty Button8 {0713F354-850A-101B-AFC0-4210102A8DA7}
Caption = "字體"
Object.ToolTipText = "字體"
Object.Tag = ""
ImageIndex = 6
EndProperty
BeginProperty Button9 {0713F354-850A-101B-AFC0-4210102A8DA7}
Caption = "打印"
Object.ToolTipText = "打印"
Object.Tag = ""
ImageIndex = 5
EndProperty
BeginProperty Button10 {0713F354-850A-101B-AFC0-4210102A8DA7}
Caption = "幫助"
Object.ToolTipText = "幫助"
Object.Tag = ""
ImageIndex = 7
EndProperty
EndProperty
End
Begin VB.TextBox Text3
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = -1 'True
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 4455
Left = 0
TabIndex = 1
Text = "平面工具欄演示的例子"
Top = 720
Width = 6855
End
Begin ComctlLib.ImageList ImageList1
Left = 6000
Top = 5160
_ExtentX = 1005
_ExtentY = 1005
BackColor = 16777215
ImageWidth = 32
ImageHeight = 32
MaskColor = 12632256
_Version = 327682
BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7}
NumListImages = 7
BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Form1.frx":0000
Key = ""
EndProperty
BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Form1.frx":031A
Key = ""
EndProperty
BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Form1.frx":0634
Key = ""
EndProperty
BeginProperty ListImage4 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Form1.frx":094E
Key = ""
EndProperty
BeginProperty ListImage5 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Form1.frx":0C68
Key = ""
EndProperty
BeginProperty ListImage6 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Form1.frx":0F82
Key = ""
EndProperty
BeginProperty ListImage7 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Form1.frx":129C
Key = ""
EndProperty
EndProperty
End
Begin VB.Menu file
Caption = "文件&F"
Begin VB.Menu new
Caption = "新建&N"
End
Begin VB.Menu openfile
Caption = "打開&O"
End
Begin VB.Menu savefile
Caption = "保存&S"
End
Begin VB.Menu sep1
Caption = "-"
End
Begin VB.Menu exitfile
Caption = "退出&X"
End
End
Begin VB.Menu editfile
Caption = "編輯&E"
End
Begin VB.Menu option
Caption = "設置&O"
End
Begin VB.Menu help
Caption = "幫助&H"
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'-------------------------------------------
' 實現WORD樣式的工具欄
'-------------------------------------------
' 洪恩在線 求知無限
'-------------------------------------------
'程序說明:
'流行軟件的工具欄上的按鈕是平的按鈕,當鼠標移過時才
'會突起,這種效果采用貼圖的方法實現十分麻煩,而利用
'API函數實現起來就很方便,快捷。
'實現的基本思路是:用SendMessage函數向工具欄發送設
'置顯示風格STYLE的消息來改變工具欄的顯示效果。
'-------------------------------------------
Const WM_USER = &H400
Const TB_SETSTYLE = WM_USER + 56
Const TB_GETSTYLE = WM_USER + 57
Const TBSTYLE_FLAT = &H800
Const TBSTYLE_LIST = &H1000
'-------------------------------------------
'【VB聲明】
' Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
'【說明】
' 在窗口列表中尋找與指定條件相符的第一個子窗口
'【返回值】
' Long,找到的窗口的句柄。如未找到相符窗口,則返回零。會設置GetLastError
'【參數表】
' hWnd1 ---------- Long,在其中查找子的父窗口。如設為零,表示使用桌面窗口(通常說的頂級窗口都被認為是桌面的子窗口,所以也會對它們進行查找)
' hWnd2 ---------- Long,從這個窗口后開始查找。這樣便可利用對FindWindowEx的多次調用找到符合條件的所有子窗口。如設為零,表示從第一個子窗口開始搜索
' lpsz1 ---------- String,欲搜索的類名。零表示忽略
' lpsz2 ---------- String,欲搜索的類名。零表示忽略
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, _
ByVal hWnd2 As Long, _
ByVal lpsz1 As String, _
ByVal lpsz2 As String) As Long
'--------------------------------------------
'【VB聲明】
' Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
'【說明】
' 調用一個窗口的窗口函數,將一條消息發給那個窗口。除非消息處理完畢,否則該函數不會返回。SendMessageBynum,
' SendMessageByString是該函數的“類型安全”聲明形式
'【返回值】
' Long,由具體的消息決定
'【參數表】
' hwnd ----------- Long,要接收消息的那個窗口的句柄
' wMsg ----------- Long,消息的標識符
' wParam --------- Long,具體取決于消息
' lParam --------- Any,具體取決于消息
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Integer, ByVal lParam As Any) As Long
'----------------------------------------------
'設置工具欄為新的樣式
Private Sub SetToolbar(tBar As Toolbar, tBarStyle As Long)
Dim lngStyle As Long
Dim lngResult As Long
Dim lngHWND As Long
'得到Toolbar的句柄
lngHWND = FindWindowEx(tBar.hwnd, 0&, _
"ToolbarWindow32", vbNullString)
'得到原有的Toolbar的樣式
lngStyle = SendMessage(lngHWND, _
TB_GETSTYLE, 0&, 0&)
'用一個Case語句給Toolbar賦不同的樣式
Select Case tBarStyle
Case 1:
'制作一個圖形在上、文字在下的平面工具欄
lngStyle = lngStyle Or TBSTYLE_FLAT
Case 2:
'制作一個圖形在左、文字在右的平面工具欄
lngStyle = lngStyle Or TBSTYLE_FLAT _
Or TBSTYLE_LIST
End Select
'用API函數實現工具欄的新樣式
lngResult = SendMessage(lngHWND, _
TB_SETSTYLE, 0, lngStyle)
'刷新工具欄
tBar.Refresh
End Sub
Private Sub exitfile_Click()
Unload Me
End Sub
Private Sub Form_Load()
'調用函數改變工具欄
Call SetToolbar(Me.Toolbar1, 1)
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -