📄 module1.bas
字号:
Attribute VB_Name = "Module1"
Public dizhi As String
'打开窗口变量声明
Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Public Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, _
ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
'注释: 具体可以使用的常量及其用法
Public Const LWA_ALPHA = &H2 '注释:表示把窗体设置成半透明样式
Public Const LWA_COLORKEY = &H1 '注释:表示不显示窗体中的透明色
Public Const WS_EX_LAYERED = &H80000
Public Const GWL_EXSTYLE = (-20)
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex _
As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As _
Long, ByVal dwNewLong As Long) As Long
Public Declare Function ReleaseCapture Lib "user32" () As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const HTCAPTION = 2
Public Const WM_NCLBUTTONDOWN = &HA1
Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal VKey As Long) As Integer
Public Const WM_StrText = &HC '发送文本
Public Const MK_Lbutton = &H1
Public Const WM_LbuttonDown = &H201
Public Const WM_LbuttonUp = &H202
Public Const WM_LbuttonDblclk = &H203
Public Declare Function SetWindowPos& Lib "user32" (ByVal hwnd&, ByVal hWndInsertAfter&, ByVal X&, ByVal Y&, ByVal cx&, ByVal cy&, ByVal wFlags&)
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
' 将窗口置于列表顶部,并位于任何最顶部窗口的前面
Private Const SWP_NOSIZE& = &H1
' 保持窗口大小
Private Const SWP_NOMOVE& = &H2
Public Function FormStyles(Yhwnd As Long, Value As Long, Styles As Long)
rtn = GetWindowLong(Yhwnd, GWL_EXSTYLE) ' 注释:取的窗口原先的样式
rtn = rtn Or WS_EX_LAYERED '注释:使窗体添加上新的样式WS_EX_LAYERED
SetWindowLong Yhwnd, GWL_EXSTYLE, rtn '注释:把新的样式赋给窗体
If Styles = 2 Then SetLayeredWindowAttributes Yhwnd, 0, CInt(Value), LWA_ALPHA
If Styles = 1 Then SetLayeredWindowAttributes Yhwnd, Value, 0, LWA_COLORKEY
End Function
'移动窗体
Public Function MoveForm(Yhwnd As Long)
ReleaseCapture
SendMessage Yhwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End Function
'前置窗体
Public Function FrontForm(Yhwnd As Long, Styles As Boolean)
If Styles Then
Call SetWindowPos(Yhwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE& Or SWP_NOMOVE&)
Else
Call SetWindowPos(Yhwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE& Or SWP_NOMOVE&)
End If
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -