]> git.saurik.com Git - wxWidgets.git/commitdiff
no real changes, just use AutoHXXX classes instead of manually creating/deleting...
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 15 Jun 2009 17:53:58 +0000 (17:53 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 15 Jun 2009 17:53:58 +0000 (17:53 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61061 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/button.cpp

index 1d4e9fa0dacd4b7d35047b1889504b0cb2661554..c2269e51176d6eb46b2fb86807342d382e0f3ecc 100644 (file)
@@ -983,12 +983,12 @@ void DrawButtonFrame(HDC hdc, const RECT& rectBtn,
     RECT r;
     CopyRect(&r, &rectBtn);
 
-    HPEN hpenBlack   = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DDKSHADOW)),
-         hpenGrey    = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW)),
-         hpenLightGr = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DLIGHT)),
-         hpenWhite   = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DHILIGHT));
+    AutoHPEN hpenBlack(GetSysColor(COLOR_3DDKSHADOW)),
+             hpenGrey(GetSysColor(COLOR_3DSHADOW)),
+             hpenLightGr(GetSysColor(COLOR_3DLIGHT)),
+             hpenWhite(GetSysColor(COLOR_3DHILIGHT));
 
-    HPEN hpenOld = (HPEN)SelectObject(hdc, hpenBlack);
+    SelectInHDC selectPen(hdc, hpenBlack);
 
     r.right--;
     r.bottom--;
@@ -1026,12 +1026,6 @@ void DrawButtonFrame(HDC hdc, const RECT& rectBtn,
         wxDrawLine(hdc, r.left + 1, r.bottom - 1, r.right - 1, r.bottom - 1);
         wxDrawLine(hdc, r.right - 1, r.bottom - 1, r.right - 1, r.top);
     }
-
-    (void)SelectObject(hdc, hpenOld);
-    DeleteObject(hpenWhite);
-    DeleteObject(hpenLightGr);
-    DeleteObject(hpenGrey);
-    DeleteObject(hpenBlack);
 }
 
 #if wxUSE_UXTHEME
@@ -1096,12 +1090,11 @@ void MSWDrawXPBackground(wxButton *button, WXDRAWITEMSTRUCT *wxdis)
     if ( button->UseBgCol() )
     {
         COLORREF colBg = wxColourToRGB(button->GetBackgroundColour());
-        HBRUSH hbrushBackground = ::CreateSolidBrush(colBg);
+        AutoHBRUSH hbrushBackground(colBg);
 
         // don't overwrite the focus rect
         ::InflateRect(&rectClient, -1, -1);
         FillRect(hdc, &rectClient, hbrushBackground);
-        ::DeleteObject(hbrushBackground);
     }
 }
 #endif // wxUSE_UXTHEME
@@ -1172,9 +1165,8 @@ bool wxButton::MSWOnDraw(WXDRAWITEMSTRUCT *wxdis)
         COLORREF colBg = wxColourToRGB(GetBackgroundColour());
 
         // first, draw the background
-        HBRUSH hbrushBackground = ::CreateSolidBrush(colBg);
+        AutoHBRUSH hbrushBackground(colBg);
         FillRect(hdc, &rectBtn, hbrushBackground);
-        ::DeleteObject(hbrushBackground);
 
         // draw the border for the current state
         bool selected = (state & ODS_SELECTED) != 0;