blog dds

2007.12.13

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.

Read and post comments, or share through   


Creative Commons License Last modified: Thursday, December 13, 2007 10:15 pm
Unless otherwise expressly stated, all original material on this page created by Diomidis Spinellis is licensed under a Creative Commons Attribution-Share Alike 3.0 Greece License.