form1.frm

来自「很好的教程原代码!」· FRM 代码 · 共 70 行

FRM
70
字号
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command1 
      Caption         =   "Command1"
      Height          =   495
      Left            =   1800
      TabIndex        =   0
      Top             =   1320
      Width           =   1215
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
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
Const WM_SETHOTKEY = &H32
Const HOTKEYF_SHIFT = &H1
Const HOTKEYF_CONTROL = &H2
Const HOTKEYF_ALT = &H4
Const HOTKEYF_EXT = &H8

Private Type tInteger
  aint As Integer
End Type
Private Type t2Byte
  lByte As Byte
  hByte As Byte
End Type
Private ii As tInteger
Private bb As t2Byte

Private Sub Command1_Click()
Dim wParam As Long, I As Long

'设定Ctrl+Shift+T 为该窗体的热键
bb.hByte = HOTKEYF_CONTROL Or HOTKEYF_SHIFT
bb.lByte = vbKeyT
LSet ii = bb

wParam = CLng(ii.aint)
I = SendMessage(Me.hwnd, WM_SETHOTKEY, wParam, 0)
If I = 1 Then
   Debug.Print "Ctl-Shift-T 为hotkey"
Else
   If I = 2 Then
     Debug.Print "有其他Window也用Ctl-Shift-T当Hotkey"
   Else
     Debug.Print "指定失败"
   End If
End If
End Sub

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?