Why does TaskDialog return immediately without showing a dialog? – Answer

Raymond Chen

Last time, I left an exercise to determine why the Task­Dialog function was not actually displaying anything. The problem had nothing to do with an invalid window handle parameter and had all to do with original window being destroyed. My psychic powers told me that the window’s WM_DESTROY handler called Post­Quit­Message. As we learned some time ago, quit messages cause modal loops to exit. Since the code was calling Task­Dialog after the window was destroyed, there was a WM_QUIT message still sitting in the queue, and that quit message caused the modal loop in Task­Dialog to exit before it got a chance to display anything. Switching to Message­Box wouldn’t have changed anything, since Message­Box responds to quit messages the same way as Task­Dialog.

(Worf was the first person to post the correct answer.)

0 comments

Discussion is closed.

Feedback usabilla icon