Homework assignment about window subclassing

Raymond Chen

Window subclassing is trickier than you think. Consider this code sketch:

// Subclass the window for a little while
WNDPROC OldWndProc = SubclassWindow(hwnd, NewWndProc);
... do stuff ...
// Okay all done, remove our subclass by
// restoring the previous window procedure
SubclassWindow(hwnd, OldWndProc);

What could go wrong? We’ll discuss it tomorrow.