1
votes

Hi I created a dialog box within win32:

ABOUTBOX DIALOG DISCARDABLE 32, 32, 180, 100
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
FONT 8, "MS Sans Serif"
BEGIN
    DEFPUSHBUTTON "OK",IDOK,66,80,50,14
    ICON "ID_MYICON_2",IDC_STATIC,0,0,48,48
    CTEXT "comment1",IDC_STATIC,40,12,100,8
    CTEXT "comment2",IDC_STATIC,7,40,166,8
    CTEXT "comment3",IDC_STATIC,7,52,166,8
END

The icon file contains different sizes of images i.e. 16x16, 32x32, 48x48 etc however the code above only allows it do be displayed as 32x32. Even if i change it to

    ICON "ID_MYICON_2",IDC_STATIC,0,0,16,16

.. it still shows as 32x32. How do you fully control icon size? My original intention was to display a bmp.

Any help most appreciated.

1
What happens if you only include a 48x48 icon file in your *.ico?Mikhail

1 Answers

2
votes

It is behavior by design. See Static Control Styles:

The style ignores the CreateWindow parameters nWidth and nHeight; the control automatically sizes itself to accommodate the icon. As it uses the LoadIcon function, the SS_ICON style can load only icons of dimensions SM_CXICON and SM_CYICON. This restriction can be bypassed by using the SS_REALSIZEIMAGE style in addition to SS_ICON.

Also, nothing prevents you from loading 48x48 icon programmatically and passing it to the control.