Windows hook and control hook 
Author Message
 Windows hook and control hook

             I am a little puzzled here.
I know, when hooking up to Windows, the application has to unhook before
My code does it as below:
lpPrevWndProc = SetWindowLong(gHwnd, GWL_WNDPROC, AddressOf WindowProc)
SetWindowLong(gHwnd, GWL_WNDPROC, lpPrevWndProc)

What about when hooking to the control?
 I use this code to align caption on the command button :
    oldStyle = GetWindowLong(Command1.hwnd, GWL_STYLE)
    oldStyle = oldStyle And (Not BS_ALLSTYLES)
    rtn = SetWindowLong(Command1.hwnd, GWL_STYLE, newStyle Or oldStyle)
Should I provide the code to unhook from the control or it is not necessary?
If yes, when should I do that:
as soon as the hook is executed or on the app termination?
Would-be this just enough:
SetWindowLong(Command1.hwnd, GWL_STYLE, rtn)

Fri, 13 Jul 2012 05:51:20 GMT  
 Windows hook and control hook
Hi Claire,

> lpPrevWndProc = SetWindowLong(gHwnd, GWL_WNDPROC, AddressOf WindowProc)

it's no hooking, but subclassing. That's a difference. And for subclassing,
when a window/control will no more exist (after closing your program) there
is no need to restore the original procedure before. But you can do it for
"clean" programming...


Fri, 13 Jul 2012 06:19:33 GMT  
 [ 2 post ] 

 Relevant Pages 

1. Mhcallback - Keyboard hook and Mouse hook , HOW!

2. Windows Keyboard Hook in .NET

3. Windows Hooks

4. VB5: Hooking Windows Messages / minimized program

5. How to hook windows in other apps ?

6. using windows HOOKS (system-wide)

7. Hook into Windows System Message Queue?

8. Hooking to the Windows Explorer...

9. Windows Hooks

10. why must hooked windows be released?

11. Windows Hooks

12. Windows hook


Powered by phpBB® Forum Software