[ wxwindows-Bugs-1862812 ] wxTopLevelWindowMSW::SetIcons fails with large fonts

SourceForge.net noreply at sourceforge.net
Wed Jan 2 17:11:46 PST 2008


Bugs item #1862812, was opened at 2008-01-03 01:43
Message generated for change (Comment added) made by vadz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1862812&group_id=9863

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: wxMSW specific
Group: Platform specific
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: David Wright (wrightd)
Assigned to: Nobody/Anonymous (nobody)
Summary: wxTopLevelWindowMSW::SetIcons fails with large fonts 

Initial Comment:
wxTopLevelWindowMSW::SetIcons assumes that small icons are 16x16 and large icons are 32x32.
On a system with large fonts (high-DPI) this is not the case.
This causes a problem when you load icons from a file because the wxICOFileHandler code loads large and small icons at the system metric size.

For example, if I have a file "icon.ico" with 16x16 and 32x32 icons that I want to use, I would do:

wxIconBundle bundle;
wxIcon icon32;
wxIcon icon16;
int iconSmall = ::GetSystemMetrics(SM_CXSMICON);
int iconLarge = ::GetSystemMetrics(SM_CXICON);

icon16.LoadFile("icon.ico", wxBITMAP_TYPE_ICO, iconSmall, iconSmall);
icon32.LoadFile("icon.ico", wxBITMAP_TYPE_ICO, iconLarge, iconLarge);
bundle.AddIcon(icon16);
bundle.AddIcon(icon32);
SetIcons(bundle);

..however the SetIcons doesn't work because the small & large icons are not 16 and 32 on high-DPI systems.

You can't simply pass 16 and 32 to wxIcon::LoadFile() either, as it checks the values you pass against GetSystemMetrics() to load the proper icon.

To fix this behavior, in wxTopLevelWindowMSW::SetIcons
change:
icons.GetIconOfExactSize(16);
to:
icons.GetIconOfExactSize(::GetSystemMetrics(SM_CXSMICON));
and:
icons.GetIconOfExactSize(32);
to:
icons.GetIconOfExactSize(::GetSystemMetrics(SM_CXICON));


----------------------------------------------------------------------

>Comment By: Vadim Zeitlin (vadz)
Date: 2008-01-03 02:11

Message:
Logged In: YES 
user_id=71618
Originator: NO

We should indeed use the system metrics here instead of hard-coding the
constants like this, thanks for noticing it. Fixed in both branches now,
please let me know if you still have any problems.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1862812&group_id=9863




More information about the wx-dev mailing list