views:

43

answers:

1

Hi,

I've got a dialog box where I need to display the standard Information icon. Here's my RC code:

ICON    "",IDC_ICON_INFORMATION,18,70,21,20

I process the WM_INITDIALOG message as follows:

HICON aIcn = LoadIcon(NULL, IDI_INFORMATION);
SendDlgItemMessage(m_hWnd, IDC_ICON_INFORMATION, STM_SETICON, (WPARAM) aIcn, 0);

Everything works great under 96 DPI: the static control displays a 32x32-pixel icon.

However, when I switch to higher DPI's (through right-clicking on the Desktop, choosing Screen resolution, and clicking Make or other items larger or smaller) the icon does not scale! Since everything else scales nicely, the icon looks visually much smaller than the neighboring text. I would expect that on 144 DPI (150%) the icon dimensions will be 48x48 pixels. I did declare my application as DPI-aware through an XML manifest.

The damnedest thing is that when I use my own custom-made icon (also coming from the RC file), everything scales perfectly. Furthermore, the MessageBox function called with the MB_ICONINFORMATION flag does display a scaled version of the icon, as well.

Given these thoughts, I assume of the following:

  1. The static control with the SS_ICON style can display scaled versions of icons.
  2. The icon resource that contains the standard Information icon has a scaled version of the icon (48x48).

What am I doing wrong then?

A: 

Use LoadImage() instead of LoadIcon(), and specify the cxDesired and cyDesired params with the values you get from GetSystemMetrics(SM_CYICON) and GetSystemMetrics(SM_CXICON).

Or maybe just declaring your app as DPI aware could be enough? You can try that easily by simple creating a text file making it a manifest file. See the example in the remarks section for the SetProcessDPIAware API

Stefan
Tried all this. The program is already DPI-aware through manifest. That's written in the original question.
Kerido