]> git.saurik.com Git - wxWidgets.git/commitdiff
assert in wxTopLevelWindowMSW::SetIcon[s]() if none of the provided icons has require...
authorVáclav Slavík <vslavik@fastmail.fm>
Thu, 16 Oct 2008 19:13:32 +0000 (19:13 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Thu, 16 Oct 2008 19:13:32 +0000 (19:13 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56374 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

interface/wx/toplevel.h
src/msw/toplevel.cpp

index 197bf2df3e37f042166fb436b0916ea827fb4ee2..aded9fab57d9dd0d8e7a81ae2832e91a8103c873 100644 (file)
@@ -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);
 
index 531e165bb6fe1219016181f4a0ffca68334bf72c..93e36350dfbadfd5178d07e7e9bef22445bcf85c 100644 (file)
@@ -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)