📄 mysecendmodule.bas
字号:
Attribute VB_Name = "MySecendModule"
Option Explicit
' 为窗口设定剪裁区;这使您能够创建出任意形状的窗口。
Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
' 创建圆角矩形区域
Private Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) 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
' m为当前的应用程序释放鼠标捕获,Long,TRUE(非零)表示成功,零表示失败
Private Declare Function ReleaseCapture Lib "user32" () As Long
' 使窗体总是处于最上层
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, Y, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
' 自定义常量
Private Const HWND_TOP = -1
Private Const HWND_NOTTOP = -2
Private Const HWND_NOTMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const HWND_NOTACTIVE = &H10
Private Const SWP_SHOWTHEWINDOW = &H40
Private Const TOP_FLAG = HWND_NOTMOVE Or SWP_NOSIZE
Public Sub AlwaysOnTop(TheForm As Form, Toggle As Boolean)
' 使窗体总是处于最上层 Toggle=true 则总是在上方,Toggle=false则为一般显示
If Toggle = True Then
SetWindowPos TheForm.hwnd, HWND_TOP, 0, 0, 0, 0, TOP_FLAG
Else
SetWindowPos TheForm.hwnd, HWND_NOTTOP, 0, 0, 0, 0, TOP_FLAG
End If
End Sub
Public Sub DrawForms(TheForm As Form)
'拖动窗体
ReleaseCapture
SendMessage TheForm.hwnd, &HA1, 2, 0&
End Sub
Public Sub SetWindow(TheForm As Form)
'设置窗体边框
TheForm.Top = 1700
TheForm.Left = 2300
TheForm.BackColor = RGB(207, 207, 207)
With TheForm!imglefttitle
.Top = 0
.Left = 0
End With
With TheForm!imgrighttitle
.Top = 0
.Left = TheForm.Width - 2
End With
With TheForm!imgtop
.Top = 0
.Left = 19
.Width = (TheForm.Width / Screen.TwipsPerPixelX) - 19
End With
With TheForm!imgleftwindow
.Top = 30
.Left = 0
.Height = (TheForm.Height / Screen.TwipsPerPixelY) - 60
End With
With TheForm!imgleftbottom
.Top = (TheForm.Height / Screen.TwipsPerPixelY) - 30
.Left = 0
End With
With TheForm!imgbottom
.Top = (TheForm.Height / Screen.TwipsPerPixelY) - 30
.Left = 19
.Width = (TheForm.Width / Screen.TwipsPerPixelX) - 38
End With
With TheForm!imgrightbottom
.Top = (TheForm.Height / Screen.TwipsPerPixelY) - 30
.Left = (TheForm.Width / Screen.TwipsPerPixelX) - 30
End With
With TheForm!imgrightwindow
.Top = 30
.Left = (TheForm.Width / Screen.TwipsPerPixelX) - 30
.Height = (TheForm.Height / Screen.TwipsPerPixelY) - 60
End With
With TheForm!imgclose
.Top = 8
.Left = (TheForm.Width / Screen.TwipsPerPixelX) - 22
End With
End Sub
Public Sub SetPixels(MyForm As Form)
Dim TempRegions(6) As Long
Dim formwidth As Long
Dim formheight As Long
Dim afterset
formwidth = MyForm.Width / Screen.TwipsPerPixelX
formheight = MyForm.Height / Screen.TwipsPerPixelY
afterset = CreateRoundRectRgn(0, 0, formwidth, formheight, 24, 24)
afterset = SetWindowRgn(MyForm.hwnd, afterset, True)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -