4

I'm working on a Windows app that needs to run on XP, Vista, 7, and 8. I'm trying to set the application icon, and it works, using DI_ICON1 as the tag in my RC file:

DI_ICON1 ICON DISCARDABLE "myapp.ico"

Using IDI_ICON1 didn't seem to do the right thing here.

However, I also create a second window (also at the root level, ie not a child of my app's main window) and the ALT-TAB icon for that second window wasn't showing up correctly; it was just the default, generic app icon. Adding a second line to the RC now made the ALT-TAB icon work:

IDI_ICON1 ICON DISCARDABLE "myapp.ico"

so with both lines everything works. But I don't know why or how or wtf these identifiers even mean. So what are they, where are they defined, and by what magic do they work?

AndrewS
  • 8,196
  • 5
  • 39
  • 53
  • Those are just arbitrary identifiers from `resource.h`. There must be some code which uses those identifiers somewhere. – nneonneo Oct 24 '12 at 16:14
  • Why use one or the other? Is there some standard definition of the two values? – AndrewS Oct 24 '12 at 16:15

1 Answers1

1

IDI_ICON1 is just a unique name identifying the resource. You can give it any name as long as it is unique. The development environment should generate a Resource.h file that uses a #define preprocessor directive to assign it a 16-bit unsigned integer unique identifier.

See:

IDI_ICON1 is probably just a convention that someone came up with, where IDI means "ID Icon", and 1 is because it is the first icon being defined. So, if you were defining another icon you'd identify it with IDI_ICON2. If you were defining a bitmap resource, you would identify it with IDB_BITMAP1.

DISCARDEABLE is only relevant for 16-bit Windows. See: https://learn.microsoft.com/en-us/windows/win32/menurc/common-resource-attributes

MangaD
  • 315
  • 4
  • 12