professionalgrammer
professionalgrammer

Reputation: 57

Setting icon in Win32 dialog to a default icon

I have an icon in a custom dialog box which I would like to be one of the icons which can simply be accessed via macros, such as MB_ICONERROR or MB_ICONINFORMATION. I know these are of course C(++) macros, so they can't just be writen into the .rc file, but I would like to display the file which they correspond to in my dialog. How can I do this? Thank you for your help.

Upvotes: 1

Views: 734

Answers (1)

Jonathan Potter
Jonathan Potter

Reputation: 37122

The LoadIcon function is able to load those standard icons. E.g. LoadIcon(nullptr, IDI_ERROR) returns the same icon that MB_ICONERROR gives you in the standard message box.

To display them in your own dialog box, use a static control with the SS_ICON style set, and then use the STM_SETICON message to assign the icon to the control.

Upvotes: 3

Related Questions