Many Ways to Skin a Window

 

Every couple of years, users of a Microsoft Windows application I wrote a long time ago start complaining that the application crashes when they exit from it. Every time it turns out that the reason is a Windows message that tells the application's main window to close in a way that was not originally foreseen.

Up to now I've collected four ways in which Windows can destroy a Window. I'm posting them here, because they may help other unfortunate puzzled souls. A window can be destroyed through the following messages.

	(msg == WM_CLOSE) ||
	(msg == WM_NCDESTROY) ||
	(msg == WM_SYSCOMMAND && wParam == SC_CLOSE) ||
	(msg == WM_NCLBUTTONDOWN && wParam == HTCLOSE);
I'm sure that on Windows Vista I'll discover yet another way.

Comments   Toot! Share


Last modified: Thursday, December 13, 2007 9:15 pm

Creative Commons Licence BY NC

Unless otherwise expressly stated, all original material on this page created by Diomidis Spinellis is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.