⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 带声音效果的按钮
💻 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 + -