Why does TaskDialog return immediately without showing a dialog?
A customer reported a problem with the
We’ve encountered a strange behavior in the
TaskDialogfunction. A user reported that when exiting our application, our program played an error beep that didn’t appear to be associated with an error. After investigating, we found that the sound is coming from our application trying to display an error dialog before closing by calling
TaskDialog. The error beep is played but no dialog appears.
Some background on the error condition that we’re trying to report: We’re calling
CreateWindowEx, and the window procedure creates another window in its
WM_CREATEhandler. It looks like the original window is destroyed before
WM_CREATEis finished, so
ERROR_INVALID_WINDOW_HANDLE. It’s not clear why this is causing
TaskDialogto fail, but this is the only scenario where we see this behavior. All other calls to
TaskDialogwork as expected. We know how to fix the original problem with
CreateWindowEx, but we would like to understand what’s going on with
TaskDialogin case there’s another bug here.
With a little bit of psychic powers, you can solve this customer’s problem too.
(If you have a good memory, you may have noticed that it’s a variation on a previous puzzle. But I get to keep recycling it because every year, a new batch of developers stumbles across the problem.)