|
-
Jul 1st, 2012, 12:52 PM
#1
Thread Starter
PowerPoster
Re: [VB6] - about Hook windows api procedure
 Originally Posted by jmsrickland
You don't call it. It is called by the OS because you have placed a procedure, MyWindowProc, in your code that replaces the default procedure that handles messages sent to the Form window.
Run app. Click on Start Subclassing. This will start the subclassing process (call it hooking if you want to). Now left mouse click on Form and that event is passed to the MyWindowProc and there you do what you want to do (in my example I just put a MsgBox but you can do whatever you want to do)
Click on Stop Subclassing. Left mouse click on Form and nothing happens because now the default Windows procedure (you don't see this one because the OS has it) gets the mouse event instead of your procedure.
My example only captures one event; WM_LBUTTONDOWN, but you can get the other events by looking at API Viewer and copying all the WM_ messages and putting them in your procedure. The only thing is you will need to know how to handle those events but at least it will get you started.
WORD OF WARNING: Subclassing can be hazardous to your program. Make sure you ALWAYS save your changes before you run your project because any error in your subclassing code will cause your project and VB IDE to crash.
So, to answer your question, the process is only driven by some event or action applied to the Form.
thanks for all
Last edited by joaquim; Jul 1st, 2012 at 01:08 PM.
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
|