自动关闭消息框.frm
来自「Windows API函数,希望大伙有用哦」· FRM 代码 · 共 46 行
FRM
46 行
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 2145
ClientLeft = 60
ClientTop = 345
ClientWidth = 6645
LinkTopic = "Form1"
ScaleHeight = 2145
ScaleWidth = 6645
StartUpPosition = 3 '窗口缺省
Begin VB.Timer Timer1
Left = 90
Top = 90
End
Begin VB.CommandButton Command1
Caption = "关闭消息框"
Height = 345
Left = 4890
TabIndex = 0
Top = 1560
Width = 1395
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
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
Private Const WM_CLOSE = &H10
Private Const MsgTitle As String = "提示信息"
Private Sub Command1_Click()
Timer1.Interval = 3000
Timer1.Enabled = True
MsgBox "若您不回应的话,3 秒后此消息框将自动关闭 ! ", vbInformation, MsgTitle
End Sub
Private Sub Timer1_Timer()
Dim hWnd As Long
Timer1.Enabled = False
hWnd = FindWindow(vbNullString, MsgTitle)
SendMessage hWnd, WM_CLOSE, 0, ByVal 0&
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?