Remove asserts in wxMSW::wxTLW::SetIcons() and always set some icon.

In practice having the icons of the exact size for all versions of Windows is
not always possible, there are just too many of them. So set the icon of the
most suitable size if no exact match is found instead of asserting in this
case.

See #11146.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65084 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2010-07-24 17:43:47 +00:00
parent 7b8e38beef
commit 7fb5d9e4cf

View File

@ -1051,14 +1051,24 @@ bool wxTopLevelWindowMSW::DoSelectAndSetIcon(const wxIconBundle& icons,
{
const wxSize size(::GetSystemMetrics(smX), ::GetSystemMetrics(smY));
const wxIcon icon = icons.GetIconOfExactSize(size);
if ( icon.Ok() )
// Try the exact size first.
wxIcon icon = icons.GetIconOfExactSize(size);
if ( !icon.IsOk() )
{
::SendMessage(GetHwnd(), WM_SETICON, i, (LPARAM)GetHiconOf(icon));
return true;
// If we didn't find any, set at least some icon: it will look scaled
// and ugly but in practice it's impossible to prevent this because not
// everyone can provide the icons in all sizes used by all versions of
// Windows in all DPIs (this would include creating them in at least
// 14, 16, 22, 32, 48, 64 and 128 pixel sizes).
icon = icons.GetIcon(size);
}
return false;
if ( !icon.IsOk() )
return false;
::SendMessage(GetHwnd(), WM_SETICON, i, (LPARAM)GetHiconOf(icon));
return true;
}
void wxTopLevelWindowMSW::SetIcons(const wxIconBundle& icons)
@ -1073,15 +1083,8 @@ void wxTopLevelWindowMSW::SetIcons(const wxIconBundle& icons)
return;
}
bool anySet =
DoSelectAndSetIcon(icons, SM_CXSMICON, SM_CYSMICON, ICON_SMALL);
if ( DoSelectAndSetIcon(icons, SM_CXICON, SM_CYICON, ICON_BIG) )
anySet = true;
if ( !anySet )
{
wxFAIL_MSG( "icon bundle doesn't contain any suitable icon" );
}
DoSelectAndSetIcon(icons, SM_CXSMICON, SM_CYSMICON, ICON_SMALL);
DoSelectAndSetIcon(icons, SM_CXICON, SM_CYICON, ICON_BIG);
}
bool wxTopLevelWindowMSW::EnableCloseButton(bool enable)