Andrew Truckle
Andrew Truckle

Reputation: 19087

How can I display the IDI_INFORMATION icon at 16 x 16 in the lower left of my dialog?

When you use a CTaskDialog you can set the footer icon, which is 16 x 16. I would like to do something similar on my own dialog:

enter image description here

At the moment my own dialog has a static resource at the bottom.


I know that I can load the information icon like this:

HICON hInfo = LoadStandardIcon(IDI_INFORMATION);
  1. How do we load it as 16 x 16?
  2. How do we display it on the left on the dialog?

Upvotes: 2

Views: 500

Answers (2)

Jabberwocky
Jabberwocky

Reputation: 50778

If you (hopefully) don't need to support Windows XP, you can use LoadIconWithScaleDown

For example:

HICON hicon;
HRESULT hr = LoadIconWithScaleDown(NULL, (PCWSTR)IDI_INFORMATION,
             GetSystemMetrics(SM_CXICON) / 2, GetSystemMetrics(SM_CYICON) / 2,  &hicon);
...

This gives you the additional benefit of loading the modern version of the icons instead of the old ugly ones. See also this SO article.

Upvotes: 3

Flaviu_
Flaviu_

Reputation: 1346

You could do it by using Picture Control, and position it whenever you want. And as code you could do:

CStatic  myicon;
myicon.Attach(GetDlgItem(ID_STATIC_ICON));
myicon.SetIcon(static_cast<HICON>(::LoadImage(nullptr, MAKEINTRESOURCE(IDI_MYICON), IMAGE_ICON, 16, 16, 0)));

I didn't test the code, but should work.

enter image description here

Upvotes: 2

Related Questions