{"id":21173,"date":"2008-08-20T10:00:00","date_gmt":"2008-08-20T10:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2008\/08\/20\/icons-and-cursors-know-where-they-came-from\/"},"modified":"2008-08-20T10:00:00","modified_gmt":"2008-08-20T10:00:00","slug":"icons-and-cursors-know-where-they-came-from","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20080820-00\/?p=21173","title":{"rendered":"Icons and cursors know where they came from"},"content":{"rendered":"<p>If you create an icon by calling <code>LoadIcon<\/code>, the window manager loads the specified icon from the module you specified, but it also remembers where the icon came from. (This discussion also applies, <i>mutatis mutandis<\/i> to cursors, but I will just talk about icons to avoid awkardness.) When you pass the <code>LR_COPYFROMRESOURCE<\/code> flag to the <code>CopyImage<\/code> function, the window manager goes back to the original icon source to create the copy you requested rather than blindly stretching the pixels of the icon you passed in.<\/p>\n<p> Remember that an ICO file represents not just one icon but rather a collection of icons (known as an &#8220;icon group&#8221;), each at a different size or color depth. The intent is that each icon in the icon group depicts the same underlying image, just tuned for particular settings. (Now, mind you, there is no enforcement of this intent. If you make your 16&times;16 image a smiling-face and your 32&times;32 image a barking dog, well, then that&#8217;s your problem.) For example, a single ICO file might contain a 16&times;16 image, a 32&times;32 image, and a 48&times;48 image. If somebody asks for the icon at one of those sizes, then the corresponding image is used. On the other hand, if somebody asks for, say, the 24&times;24 image, the window manager will take the 32&times;32 image and stretch it to the necessary size. <\/p>\n<p> You can recover this &#8220;hidden source information&#8221; with the <code>GetIconInfoEx<\/code> function (new for Windows&nbsp;Vista). If the icon was loaded by ordinal, then the <code>szResName<\/code> is an empty string and the ordinal is placed in the <code>wResID<\/code> member. If the icon was loaded by name, then <code>wResID<\/code> is zero and <code>szResName<\/code> contains the resource name. <\/p>\n<p> This is just some background information about icons (and cursors). Next time, we&#8217;ll put this information to use to solve a problem. <\/p>\n<p> [Raymond is currently away; this message was pre-recorded.] <\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you create an icon by calling LoadIcon, the window manager loads the specified icon from the module you specified, but it also remembers where the icon came from. (This discussion also applies, mutatis mutandis to cursors, but I will just talk about icons to avoid awkardness.) When you pass the LR_COPYFROMRESOURCE flag to 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":[26],"class_list":["post-21173","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>If you create an icon by calling LoadIcon, the window manager loads the specified icon from the module you specified, but it also remembers where the icon came from. (This discussion also applies, mutatis mutandis to cursors, but I will just talk about icons to avoid awkardness.) When you pass the LR_COPYFROMRESOURCE flag to the [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/21173","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=21173"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/21173\/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=21173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=21173"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=21173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}