From 0f278d7763de93b4ddacb3f553de0006585407c8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Thu, 16 Oct 2008 19:13:32 +0000 Subject: [PATCH] assert in wxTopLevelWindowMSW::SetIcon[s]() if none of the provided icons has required size git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56374 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- interface/wx/toplevel.h | 9 +++++++-- src/msw/toplevel.cpp | 12 +++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/interface/wx/toplevel.h b/interface/wx/toplevel.h index 197bf2df3e..aded9fab57 100644 --- a/interface/wx/toplevel.h +++ b/interface/wx/toplevel.h @@ -222,7 +222,9 @@ public: reference counting, the copy is very quick. It is safe to delete @a icon after calling this function. - @see wxIcon + @note In wxMSW, @a icon must be either 16x16 or 32x32 icon. + + @see wxIcon, SetIcons() */ void SetIcon(const wxIcon& icon); @@ -235,7 +237,10 @@ public: @param icons The icons to associate with this window. - @see wxIconBundle. + @note In wxMSW, @a icons must contain a 16x16 or 32x32 icon, + preferably both. + + @see wxIconBundle */ virtual void SetIcons(const wxIconBundle& icons); diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index 531e165bb6..93e36350df 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -972,7 +972,7 @@ wxString wxTopLevelWindowMSW::GetTitle() const return GetLabel(); } -void wxTopLevelWindowMSW::DoSelectAndSetIcon(const wxIconBundle& icons, +bool wxTopLevelWindowMSW::DoSelectAndSetIcon(const wxIconBundle& icons, int smX, int smY, int i) @@ -983,15 +983,21 @@ void wxTopLevelWindowMSW::DoSelectAndSetIcon(const wxIconBundle& icons, if ( icon.Ok() ) { ::SendMessage(GetHwnd(), WM_SETICON, i, (LPARAM)GetHiconOf(icon)); + return true; } + + return false; } void wxTopLevelWindowMSW::SetIcons(const wxIconBundle& icons) { wxTopLevelWindowBase::SetIcons(icons); - DoSelectAndSetIcon(icons, SM_CXSMICON, SM_CYSMICON, ICON_SMALL); - DoSelectAndSetIcon(icons, SM_CXICON, SM_CYICON, ICON_BIG); + bool ok = DoSelectAndSetIcon(icons, SM_CXSMICON, SM_CYSMICON, ICON_SMALL); + if ( DoSelectAndSetIcon(icons, SM_CXICON, SM_CYICON, ICON_BIG) ) + ok = true; + + wxASSERT_MSG( ok, "icon bundle doesn't contain any suitable icon" ); } bool wxTopLevelWindowMSW::EnableCloseButton(bool enable) -- 2.45.2