don't hardcode 16/32 as sizes for small/normal icons (fixes bug 1862812)
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 3 Jan 2008 01:13:44 +0000 (01:13 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 3 Jan 2008 01:13:44 +0000 (01:13 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50999 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/msw/toplevel.h
src/msw/toplevel.cpp

index 14a1c96cc5abdf2c69d37e33e72da775cc1d96f3..107f4c271d01ed54999059a7221f47744e1ca460 100644 (file)
@@ -312,6 +312,7 @@ All (GUI):
 wxMSW:
 
 - Fix rare bug with messages delivered to wrong wxSocket (Tim Kosse)
+- Fix setting icons when they have non-default (16*16 and 32*32) sizes
 
 
 2.8.7
index 3938b96e62b8f114d41c56b5e3edfc46baa5a170..b4f4e0ae0352281ef5520b5b6b16bc64d4799b1e 100644 (file)
@@ -142,6 +142,11 @@ protected:
     virtual void DoGetSize(int *width, int *height) const;
 #endif // __WXWINCE__
 
+    // helper of SetIcons(): calls gets the icon with the size specified by the
+    // given system metrics (SM_C{X|Y}[SM]ICON) from the bundle and sets it
+    // using WM_SETICON with the specified wParam (ICOM_SMALL or ICON_BIG)
+    void DoSelectAndSetIcon(const wxIconBundle& icons, int smX, int smY, int i);
+
 
     // is the window currently iconized?
     bool m_iconized;
index 57e85c391357ed0d9c361e90be360b9243569892..a7217b5c9181c7196494004af13848519807aee6 100644 (file)
@@ -965,25 +965,26 @@ wxString wxTopLevelWindowMSW::GetTitle() const
     return GetLabel();
 }
 
-void wxTopLevelWindowMSW::SetIcons(const wxIconBundle& icons)
+void wxTopLevelWindowMSW::DoSelectAndSetIcon(const wxIconBundle& icons,
+                                             int smX,
+                                             int smY,
+                                             int i)
 {
-    wxTopLevelWindowBase::SetIcons(icons);
+    const wxSize size(::GetSystemMetrics(smX), ::GetSystemMetrics(smY));
 
-#if !defined(__WXMICROWIN__)
-    const wxIcon& sml = icons.GetIconOfExactSize(16);
-    if( sml.Ok() )
+    const wxIcon icon = icons.GetIconOfExactSize(size);
+    if ( icon.Ok() )
     {
-        ::SendMessage( GetHwndOf( this ), WM_SETICON, ICON_SMALL,
-                       (LPARAM)GetHiconOf(sml) );
+        ::SendMessage(GetHwnd(), WM_SETICON, i, (LPARAM)GetHiconOf(icon));
     }
+}
 
-    const wxIcon& big = icons.GetIconOfExactSize(32);
-    if( big.Ok() )
-    {
-        ::SendMessage( GetHwndOf( this ), WM_SETICON, ICON_BIG,
-                       (LPARAM)GetHiconOf(big) );
-    }
-#endif // !__WXMICROWIN__
+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 wxTopLevelWindowMSW::EnableCloseButton(bool enable)