hookmod.bas
来自「文件传送」· BAS 代码 · 共 54 行
BAS
54 行
Attribute VB_Name = "hookmod"
Option Explicit
Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam 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
Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" ( _
lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long)
Public Const GWL_WNDPROC = -4
'在这里写下要拦下消息的常量定义
Public defWndProc As Long
Type rect
left As Long
top As Long
right As Long
bottom As Long
End Type
Public Sub Hook(hwnd As Long)
If defWndProc = 0 Then defWndProc = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub
Public Sub UnHook(hwnd As Long)
If defWndProc > 0 Then
Call SetWindowLong(hwnd, GWL_WNDPROC, defWndProc)
defWndProc = 0
End If
End Sub
Public Function WindowProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If Msg = &H216 Then
Dim WPOS As rect
CopyMemory WPOS, ByVal lParam, Len(WPOS)
Form2.top = WPOS.top
Form2.left = WPOS.left + Form1.Width
End If
WindowProc = CallWindowProc(defWndProc, hwnd, uMsg, wParam, lParam)
End Select
End Function
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?