For readers of this code:
1. In the error checking for the UnHook I left out one line after the
lpPrevWndProc = SetWindowLong(....)
lpPrevWndProc = 0
2. Change the Gc0 to 0
(I use Gc0% as a constant for the number 0)
3. The purpose of the additional error checking is so that if you decide to use the code for other reasons, that you do not forget to Unhook before hooking again, and to make sure the same hWnd is used for unhooking, that was used with hooking.
4. There are many other possibilities to use this. You can capture almost anything you would expect and more(WM_LBUTTONDOWN mouse,WM_KEYDOWN keyboard, CBN_DROPDOWN the list box portion of a combo box "BeforeVisible" event, etc, etc, etc. - check constants in the API viewer) of a window.
5. If you want to cancel proccessing of an event then after capturing it in the WindowProc, set the return value of the function to WindowProc = Gc1, and the event will never execute in the window's (form or control) event.
To StrongM:
I only wanted users of this code to be aware when not using error checking, but didn't want to impose on your great explaination, but rather, leave that up to you....Esp. if someone doesn't use it only in this way, but in addition to other possibilities, which could cause problems if not Hooked/Unhooked when properly.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.