{"id":21543,"date":"2008-07-21T10:00:00","date_gmt":"2008-07-21T10:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2008\/07\/21\/messageboxindirect-loads-the-icon-itself-you-cant-hand-it-a-pre-loaded-icon\/"},"modified":"2008-07-21T10:00:00","modified_gmt":"2008-07-21T10:00:00","slug":"messageboxindirect-loads-the-icon-itself-you-cant-hand-it-a-pre-loaded-icon","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20080721-00\/?p=21543","title":{"rendered":"MessageBoxIndirect loads the icon itself; you can&#8217;t hand it a pre-loaded icon"},"content":{"rendered":"<p>Commenter <a href=\"http:\/\/blogs.msdn.com\/oldnewthing\/pages\/407234.aspx#519342\"> 8<\/a> wants to know how to tell the <code>MessageBoxIndirect<\/code> function to use an existing <code>HICON<\/code> instead of pointing it to an icon resource.<\/p>\n<p> You can&#8217;t. <\/p>\n<p> The <code>MessageBoxIndirect<\/code> loads the icon itself. You can&#8217;t hand it a pre-loaded icon. <\/p>\n<p> Of course, it&#8217;s hardly rocket science to write your own <code>MessageBoxWithMyIcon<\/code> function that lets you use whatever icon you want. There&#8217;s no law that says all Yes\/No dialogs must use the <code>MessageBox<\/code> function. Feel free to write your own. <\/p>\n<p> The <code>MessageBox<\/code> and <code>MessageBoxIndirect<\/code> functions are just convenience functions. They don&#8217;t create new functionality; they don&#8217;t do anything you couldn&#8217;t already do yourself. You can have a template dialog box that you use for &#8220;generic&#8221; purposes and set the icon and text yourself. Or, if you&#8217;re really adventuresome, you can <a href=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2005\/04\/29\/412577.aspx\"> generate a dialog template on the fly<\/a>. <\/p>\n<p> The <code>MessageBox<\/code> and <code>MessageBoxIndirect<\/code> functions never aspired to be &#8220;everything anybody could ever do with a dialog box.&#8221; They just provide some basic functionality that lots of people find useful. If you need more functionality, then you can always write it yourself. (There&#8217;s already a function for &#8220;everything anybody could ever do with a standard Win32 dialog box&#8221;: It&#8217;s called, um, <code>DialogBox<\/code>.) <\/p>\n<p> Windows&nbsp;Vista introduces a considerably more customizable &#8220;message box&#8221;-type dialog known as a <a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/ms650910.aspx\"> Task Dialog<\/a>; you may want to give that one a try. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Commenter 8 wants to know how to tell the MessageBoxIndirect function to use an existing HICON instead of pointing it to an icon resource. You can&#8217;t. The MessageBoxIndirect loads the icon itself. You can&#8217;t hand it a pre-loaded icon. Of course, it&#8217;s hardly rocket science to write your own MessageBoxWithMyIcon function that lets you use [&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-21543","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Commenter 8 wants to know how to tell the MessageBoxIndirect function to use an existing HICON instead of pointing it to an icon resource. You can&#8217;t. The MessageBoxIndirect loads the icon itself. You can&#8217;t hand it a pre-loaded icon. Of course, it&#8217;s hardly rocket science to write your own MessageBoxWithMyIcon function that lets you use [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/21543","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=21543"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/21543\/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=21543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=21543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=21543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}