From 9c956c0a5942859852c03c520f1daa54866347b5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 15 Jun 2009 17:53:58 +0000 Subject: [PATCH] no real changes, just use AutoHXXX classes instead of manually creating/deleting objects in owner drawing code git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61061 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/button.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/msw/button.cpp b/src/msw/button.cpp index 1d4e9fa0da..c2269e5117 100644 --- a/src/msw/button.cpp +++ b/src/msw/button.cpp @@ -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; -- 2.49.0