📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "设置窗体置顶"
ClientHeight = 3135
ClientLeft = 60
ClientTop = 405
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3135
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "取消置顶"
Height = 495
Left = 2520
TabIndex = 1
Top = 2160
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "置顶"
Height = 495
Left = 720
TabIndex = 0
Top = 2160
Width = 1095
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 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
Private Sub OnTop(hwnd As Long, Flag As Boolean)
Const SWP_NOMOVE = 2
Const SWP_NOSIZE = 1
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
If Flag = True Then
SetWindowPos hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
Else
SetWindowPos hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End If
End Sub
'按钮
Private Sub Command1_Click()
OnTop Me.hwnd, True '置顶
End Sub
Private Sub Command2_Click()
OnTop Me.hwnd, False '取消置顶
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -