1,486
社区成员
发帖
与我相关
我的任务
分享
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GWL_WNDPROC = (-4)
Private Sub Command1_Click()
ysWindowProc = GetWindowLong(Me.hWnd, GWL_WNDPROC)
FunctionProc = SetWindowLong(Me.hWnd, GWL_WNDPROC, AddressOf WindowProc)
CommonDialog1.DialogTitle = "打开"
CommonDialog1.ShowOpen
End Sub
Public ysWindowProc As Long
Public FunctionProc As Long
Private 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
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GWL_WNDPROC = (-4)
Public Function WindowProc(ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Dim dghWnd As Long
dghWnd = FindWindow("#32770", "打开")
If dghWnd <> 0 Then
Form1.Label1.Caption = "目标窗口:" & dghWnd
SetWindowLong hWnd, GWL_WNDPROC, ysWindowProc
Else
WindowProc = CallWindowProc(FunctionProc, hWnd, wMsg, wParam, lParam)
End If
End Function