From: Claire on
Hello,
I am a little puzzled here.
I know, when hooking up to Windows, the application has to unhook before
termination.
My code does it as below:
'Hook
lpPrevWndProc = SetWindowLong(gHwnd, GWL_WNDPROC, AddressOf WindowProc)
'UnHook
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)
?
Thanks,
Claire


From: Juergen Thuemmler on
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...

Juergen.


 | 
Pages: 1
Prev: ElseIf into a For Next
Next: Linux