{"id":8293,"date":"2012-02-16T07:00:00","date_gmt":"2012-02-16T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2012\/02\/16\/why-does-the-drawicon-function-draw-at-the-default-icon-size\/"},"modified":"2012-02-16T07:00:00","modified_gmt":"2012-02-16T07:00:00","slug":"why-does-the-drawicon-function-draw-at-the-default-icon-size","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20120216-00\/?p=8293","title":{"rendered":"Why does the DrawIcon function draw at the default icon size?"},"content":{"rendered":"<p>Miral wondered <a href=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2010\/07\/29\/10043635.aspx#10044060\"> why the <code>Draw&shy;Icon<\/code> function draws at the default icon size instead of respecting the actual icon size<\/a>. After all, if you loaded a nonstandard-sized icon via <code>Load&shy;Image<\/code>, then presumably you want to use that nonstandard size.\n The question is one of those types of questions that fails to understand history, like asking why NASA didn&#8217;t send the space shuttle to rescue the Apollo&nbsp;13 astronauts.\n At the time the <code>Draw&shy;Icon<\/code> function was written, the <code>Load&shy;Image<\/code> function didn&#8217;t exist, and wouldn&#8217;t exist for over a decade. The <code>Load&shy;Image<\/code> function showed up in Windows&nbsp;95, but Windows was drawing icons long before then, and for a long time, the only way to load icons was with the <code>Load&shy;Icon<\/code> function, which always loaded icons at their default size. When the ability to create nonstandard-sized icons was added, you then had the question of how to draw them. Code which relied on the fact that all icons were the same size would call <code>Draw&shy;Icon<\/code> expecting the result to be a 32&times;32 image (or whatever your icon size was). If you drew it at its actual size, you would either have this L-shaped &#8220;hole&#8221; in the application (if the actual size was smaller), or you would have an icon that overflowed some other part of the application. Either way you lose.\n Therefore, <code>Draw&shy;Icon<\/code> always draws at the standard icon size. Think of it as <code>Draw&shy;Icon&shy;Back&shy;Compat<\/code>. If you are a fancy new application that can handle icons at nonstandard sizes, then use <code>Draw&shy;Icon&shy;Ex<\/code> and don&#8217;t pass the <code>DI_DEFAULT&shy;SIZE<\/code> flag.\n <b>Bonus chatter<\/b>: The documentation states that the <code>DI_COMPAT<\/code> has no effect. Presumably it had an effect in some previous version of Windows?\n In Windows&nbsp;95, if you used the <code>LoadCursor<\/code> to load a standard cursor (like, say, <code>IDC_ARROW<\/code>), but the standard arrow cursor was customized by the user, Windows would draw the customized cursor. Passing the <code>DI_COMPAT<\/code> flag forced the standard arrow cursor to be drawn. <strike>So far as I can tell, nobody ever passed that flag.<\/strike><\/p>\n<p> <b>Update<\/b>: My claim that nobody passed that flag is incorrect. The <code>Draw&shy;Icon<\/code> function itself passed that flag (and still does today, even though it no longer does anything). <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Miral wondered why the Draw&shy;Icon function draws at the default icon size instead of respecting the actual icon size. After all, if you loaded a nonstandard-sized icon via Load&shy;Image, then presumably you want to use that nonstandard size. The question is one of those types of questions that fails to understand history, like asking why [&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":[2],"class_list":["post-8293","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-history"],"acf":[],"blog_post_summary":"<p>Miral wondered why the Draw&shy;Icon function draws at the default icon size instead of respecting the actual icon size. After all, if you loaded a nonstandard-sized icon via Load&shy;Image, then presumably you want to use that nonstandard size. The question is one of those types of questions that fails to understand history, like asking why [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/8293","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=8293"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/8293\/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=8293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=8293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=8293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}