|
-
Jul 1st, 2012, 12:24 PM
#1
Thread Starter
PowerPoster
Re: [VB6] - about Hook windows api procedure
 Originally Posted by jmsrickland
In your Form code
Code:
Private Sub Command1_Click()
OldWindowProc = SetWindowLong(Me.hWnd, GWL_WNDPROC, AddressOf MyWindowProc)
End Sub
Private Sub Command2_Click()
'
' Restore the old window procedure before exiting
'
SetWindowLong Me.hWnd, GWL_WNDPROC, OldWindowProc
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim frm As Form
'
' Restore the old window procedure before exiting
'
SetWindowLong Me.hWnd, GWL_WNDPROC, OldWindowProc
Unload Me
End Sub
In your Module code
Code:
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 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 Const WM_LBUTTONDOWN = &H201
Public OldWindowProc As Long
Public Const GWL_WNDPROC& = (-4)
Public Function MyWindowProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim Processed As Boolean
Select Case uMsg
Case WM_LBUTTONDOWN
MsgBox "Left Button Down"
Processed = True
Case Else
MyWindowProc = CallWindowProc(OldWindowProc, hWnd, uMsg, wParam, lParam)
End Select
If Processed Then
MyWindowProc = CallWindowProc(OldWindowProc, hWnd, uMsg, wParam, lParam)
End If
End Function
yes... i'm speak about these code.
what term you use for call it?
can i use these code for normal loop, or it's only for computer\user actions?
(can i calculate milliseconds with these code?)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|