{"id":12603,"date":"2010-10-07T07:00:00","date_gmt":"2010-10-07T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2010\/10\/07\/why-does-taskdialog-return-immediately-without-showing-a-dialog\/"},"modified":"2010-10-07T07:00:00","modified_gmt":"2010-10-07T07:00:00","slug":"why-does-taskdialog-return-immediately-without-showing-a-dialog","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20101007-00\/?p=12603","title":{"rendered":"Why does TaskDialog return immediately without showing a dialog?"},"content":{"rendered":"<p>A customer reported a problem with the <code>Task&shy;Dialog<\/code> function.<\/p>\n<blockquote class=\"q\"><p>  We&#8217;ve encountered a strange behavior in the <code>Task&shy;Dialog<\/code> function. A user reported that when exiting our application, our program played an error beep that didn&#8217;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 <code>Task&shy;Dialog<\/code>. The error beep is played but no dialog appears. <\/p>\n<p> Some background on the error condition that we&#8217;re trying to report: We&#8217;re calling <code>Create&shy;Window&shy;Ex<\/code>, and the window procedure creates another window in its <code>WM_CREATE<\/code> handler. It looks like the original window is destroyed before <code>WM_CREATE<\/code> is finished, so <code>Create&shy;Window&shy;Ex<\/code> returns <code>ERROR_INVALID_WINDOW_HANDLE<\/code>. It&#8217;s not clear why this is causing <code>Task&shy;Dialog<\/code> to fail, but this is the only scenario where we see this behavior. All other calls to <code>Task&shy;Dialog<\/code> work as expected. We know how to fix the original problem with <code>Create&shy;Window&shy;Ex<\/code>, but we would like to understand what&#8217;s going on with <code>Task&shy;Dialog<\/code> in case there&#8217;s another bug here. <\/p>\n<\/blockquote>\n<p> With a little bit of psychic powers, you can solve this customer&#8217;s problem too.<\/p>\n<p> (If you have a good memory, you may have noticed that <a href=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2008\/05\/20\/8520129.aspx\"> it&#8217;s a variation on a previous puzzle<\/a>. But I get to keep recycling it because every year, a new batch of developers stumbles across the problem.) <\/p>\n","protected":false},"excerpt":{"rendered":"<p>A customer reported a problem with the Task&shy;Dialog function. We&#8217;ve encountered a strange behavior in the Task&shy;Dialog function. A user reported that when exiting our application, our program played an error beep that didn&#8217;t appear to be associated with an error. After investigating, we found that the sound is coming from our application trying to [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-12603","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>A customer reported a problem with the Task&shy;Dialog function. We&#8217;ve encountered a strange behavior in the Task&shy;Dialog function. A user reported that when exiting our application, our program played an error beep that didn&#8217;t appear to be associated with an error. After investigating, we found that the sound is coming from our application trying to [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/12603","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=12603"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/12603\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=12603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=12603"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=12603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}