📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "保持窗体显示在最前面"
ClientHeight = 2124
ClientLeft = 48
ClientTop = 336
ClientWidth = 3468
LinkTopic = "Form1"
ScaleHeight = 2124
ScaleWidth = 3468
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command1
Caption = "显示在最前面"
Height = 492
Left = 1200
TabIndex = 0
Top = 840
Width = 1212
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim OnTop As Boolean
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
' SetWindowPos Flags
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
' SetWindowPos() hwndInsertAfter values
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Private Sub Command1_Click()
OnTop = Not OnTop
If OnTop Then
Command1.Caption = "取消显示模式"
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE
Form2.Show
Else
Command1.Caption = "显示在最前面"
SetWindowPos Me.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -