Thursday, September 24, 2009

Window subclassing is tricky




Window subclassing is tricky, and as a general rule one should not attempt to dynamically sub-class and unsubclass an HWDN multiple times
during its lifetime. Instead subclass once at the HWND creation time, and then un-subclass at the HWND destruction time.
ONLY un-subclass if the value of GWLP_WNDPROC matches your window proc.
In general, you do not know if other subclasses will unsubclass at WM_DESTROY or WM_NCDESTROY time, so it is safest if it attempt to unsubclass
rst in WM_DESTROY time, and then (if that does not succeed) at WM_NCDESTROY time. You willnot get a WM_NCDESTROY
message if you were able to unsubclass in response to the WM_DESTROY message.

No comments: