{"id":13293,"date":"2010-07-29T07:00:00","date_gmt":"2010-07-29T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2010\/07\/29\/why-is-my-icon-being-drawn-at-the-wrong-size-when-i-call-drawicon\/"},"modified":"2010-07-29T07:00:00","modified_gmt":"2010-07-29T07:00:00","slug":"why-is-my-icon-being-drawn-at-the-wrong-size-when-i-call-drawicon","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20100729-00\/?p=13293","title":{"rendered":"Why is my icon being drawn at the wrong size when I call DrawIcon?"},"content":{"rendered":"<p>\nSome time ago I had a problem with icon drawing.\nWhen I tried to draw an icon with <code>Draw&shy;Icon<\/code>\nit ended up being drawn at the wrong size.\nA call to\n<code>Get&shy;Icon&shy;Info<\/code> confirmed that the icon was\n48&times;48, but it drew at 32&times;32.\n<\/p>\n<p>\nThe answer is documented in a backwards sort of way\nin the <code>Draw&shy;Icon&shy;Ex<\/code> function, which says at the bottom,\n<\/p>\n<blockquote CLASS=\"m\">\n<p>\nTo duplicate DrawIcon (hDC, X, Y, hIcon), call <b>DrawIconEx<\/b> as follows:\n<\/p>\n<pre>\nDrawIconEx (hDC, X, Y, hIcon, 0, 0, 0, NULL,\n            DI_NORMAL | DI_COMPAT | DI_DEFAULTSIZE);\n<\/pre>\n<\/blockquote>\n<p>\nAha, if you use <code>Draw&shy;Icon<\/code>, then the icon size is ignored\nand it is drawn with <code>DI_DEFAULT&shy;SIZE<\/code>.\n<\/p>\n<p>\nThe fix, therefore, was to switch to the <code>Draw&shy;Icon&shy;Ex<\/code>\nfunction so I could remove the <code>DI_DEFAULT&shy;SIZE<\/code> flag,\nthereby permitting the icon to be drawn at its actual size.\n<\/p>\n<pre>\n- DrawIcon(hdc, pt.x, pt.y, hico);\n+ DrawIcon<font COLOR=\"red\">Ex<\/font>(hdc, pt.x, pt.y, hico, <font COLOR=\"red\">0, 0, 0, NULL, DI_NORMAL | DI_COMPAT<\/font>);\n<\/pre>\n<p>\nA bonus quirk of the\n<code>DI_DEFAULT&shy;SIZE<\/code> flag\n(and therefore of the\n<code>Draw&shy;Icon<\/code> function)\nis that the drawing is done at the default <i>icon<\/i> size,\neven if you asked it to draw a <i>cursor<\/i>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some time ago I had a problem with icon drawing. When I tried to draw an icon with Draw&shy;Icon it ended up being drawn at the wrong size. A call to Get&shy;Icon&shy;Info confirmed that the icon was 48&times;48, but it drew at 32&times;32. The answer is documented in a backwards sort of way in the [&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-13293","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Some time ago I had a problem with icon drawing. When I tried to draw an icon with Draw&shy;Icon it ended up being drawn at the wrong size. A call to Get&shy;Icon&shy;Info confirmed that the icon was 48&times;48, but it drew at 32&times;32. The answer is documented in a backwards sort of way in the [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/13293","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=13293"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/13293\/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=13293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=13293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=13293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}