Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2005 May : SetWindowLong and Message Queue
| Subject: | SetWindowLong and Message Queue |
| Posted by: | "Morgan" (morgan@nospam.com) |
| Date: | Tue, 31 May 2005 00:38:49 |
I'm using a Win32 subclass to hook the messages of a TWinControl:
FOldWndProc := SetWindowLong(AHandle, GWL_WNDPROC, Integer(FNewWndProc))
After I'm done subclassing, I call:
SetWindowLong(AHandle, GWL_WNDPROC, Integer(FOldWndProc))
to reset the WndProc to the old value. Both functions succeed (do not
return 0, and I can intercept the control's messages as expected in the
FNewWndProc. The problem is that after I reset of the WndProc back to
the original value and free the class that contained the new WndProc
hook method, the subclassed WndProc (FNewWndProc) still seems to be
getting called or something, because the next message coming to the
control appears to crash with a nil pointer dereference (I think) in my
old (now freed) class. It is possible that windows messages already in
the message queue do not get updated to go to the WndProc I just set,
and the change in WndProc only takes place after the message queue
drains? Or are there any other ideas what I might be doing wrong?
Thanks a lot for any help!