Should we add unsubclass code during dialog destruction?
Question
What will happen when we subclass a windows dialog and dialog is closed?
Scenario is that I am subclassing a dialog and application can launch many instances of that dialog.
Is it necessary to add unsubclassing code to all the dialogs in thier destruction logic.
I think when dialogs get closed there is no need to unsubclass them because dialogs already destroyed.
Solution
If you're using instance subclassing (SetWindowLongPtr), then since when the window gets torn down it doesn't matter which WndProc it's using--it's about to vanish anyway.
If you're using global subclassing (SetClassLongPtr) then it would probably be a good idea to remove the subclass once the last subclassed window is closed (i.e. not per window) so that any future windows created with that class don't get subclassed--unless that's what you want, of course.
OTHER TIPS
Assuming you're talking straight Win32 API, then yes. Though be aware that if you've any resources you're managing manually, you must have tidied them up in the WM_CLOSE message.