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--;
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
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
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;