I've just been reading that WM_DESTROY is sent directly to a window's WndProc, bypassing its message queue. So if I had some code like this:-

Code:
MSG msg;

while (GetMessage (&msg, NULL, 0, 0)) {
	if (WM_DESTROY == msg.message)
		set_some_flag();
	TranslateMessage( &msg );
	DispatchMessageA (&msg);
}
The flag would never get set - because WM_DESTROY never appears in my message queue. In fact I've just tried that and it seems to be true.

So is there a way for me to know that WM_DESTROY has been (or is about to be) sent? For example is there any other message that Windows sends to notify the client that WM_DESTROY is about to be sent? This is a plain vanilla (Petzold style) app BTW - not using MFC.