Skip to content

Commit

Permalink
use AutoDeleteBrush some more
Browse files Browse the repository at this point in the history
  • Loading branch information
kjk committed Oct 28, 2023
1 parent c76414b commit 65f12cc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/Canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,13 +759,13 @@ static void PaintPageFrameAndShadow(HDC hdc, Rect& bounds, Rect& pageRect, bool

// Draw shadow
if (!presentation) {
ScopedGdiObj<HBRUSH> brush(CreateSolidBrush(COL_PAGE_SHADOW));
AutoDeleteBrush brush = CreateSolidBrush(COL_PAGE_SHADOW);
FillRect(hdc, &shadow.ToRECT(), brush);
}

// Draw frame
ScopedGdiObj<HPEN> pe(CreatePen(PS_SOLID, 1, presentation ? TRANSPARENT : COL_PAGE_FRAME));
ScopedGdiObj<HBRUSH> brush(CreateSolidBrush(gCurrentTheme->window.backgroundColor));
AutoDeleteBrush brush = CreateSolidBrush(gCurrentTheme->window.backgroundColor);
SelectObject(hdc, pe);
SelectObject(hdc, brush);
Rectangle(hdc, frame.x, frame.y, frame.x + frame.dx, frame.y + frame.dy);
Expand Down Expand Up @@ -889,11 +889,11 @@ static void DrawDocument(MainWindow* win, HDC hdc, RECT* rcArea) {
auto gcols = gGlobalPrefs->fixedPageUI.gradientColors;
auto nGCols = gcols->size();
if (paintOnBlackWithoutShadow) {
ScopedGdiObj<HBRUSH> brush(CreateSolidBrush(WIN_COL_BLACK));
AutoDeleteBrush brush = CreateSolidBrush(WIN_COL_BLACK);
FillRect(hdc, rcArea, brush);
} else if (0 == nGCols) {
auto col = GetMainWindowBackgroundColor();
ScopedGdiObj<HBRUSH> brush(CreateSolidBrush(col));
AutoDeleteBrush brush = CreateSolidBrush(col);
FillRect(hdc, rcArea, brush);
} else {
COLORREF colors[3];
Expand Down Expand Up @@ -1569,7 +1569,7 @@ static void OnPaintError(MainWindow* win) {
HFONT fontRightTxt = CreateSimpleFont(hdc, "MS Shell Dlg", 14);
HGDIOBJ hPrevFont = SelectObject(hdc, fontRightTxt);
auto bgCol = GetMainWindowBackgroundColor();
ScopedGdiObj<HBRUSH> bgBrush(CreateSolidBrush(bgCol));
AutoDeleteBrush bgBrush = CreateSolidBrush(bgCol);
FillRect(hdc, &ps.rcPaint, bgBrush);
// TODO: should this be "Error opening %s"?
auto tab = win->CurrentTab();
Expand Down
6 changes: 3 additions & 3 deletions src/HomePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,13 @@ static void DrawAbout(HWND hwnd, HDC hdc, Rect rect, Vec<StaticLinkInfo*>& stati
Rect rc = ClientRect(hwnd);
RECT rTmp = ToRECT(rc);
col = GetMainWindowBackgroundColor();
ScopedGdiObj<HBRUSH> brushAboutBg(CreateSolidBrush(col));
AutoDeleteBrush brushAboutBg = CreateSolidBrush(col);
FillRect(hdc, &rTmp, brushAboutBg);

/* render title */
Rect titleRect(rect.TL(), CalcSumatraVersionSize(hwnd, hdc));

AutoDeleteBrush bgBrush(CreateSolidBrush(col));
AutoDeleteBrush bgBrush = CreateSolidBrush(col);
ScopedSelectObject brush(hdc, bgBrush);
ScopedSelectObject pen(hdc, penBorder);
#ifndef ABOUT_USE_LESS_COLORS
Expand Down Expand Up @@ -724,7 +724,7 @@ void DrawHomePage(MainWindow* win, HDC hdc, FileHistory& fileHistory, COLORREF t
rc.dy -= titleBox.dy;
rTmp = ToRECT(rc);
col = GetMainWindowBackgroundColor();
ScopedGdiObj<HBRUSH> brushAboutBg(CreateSolidBrush(col));
AutoDeleteBrush brushAboutBg = CreateSolidBrush(col);
FillRect(hdc, &rTmp, brushAboutBg);
rc.dy -= kDocListBottomBoxDy;

Expand Down
2 changes: 1 addition & 1 deletion src/SumatraProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ static void DrawProperties(HWND hwnd, HDC hdc) {
Rect rcClient = ClientRect(hwnd);
RECT rTmp = ToRECT(rcClient);
auto col = GetMainWindowBackgroundColor();
ScopedGdiObj<HBRUSH> brushAboutBg(CreateSolidBrush(col));
AutoDeleteBrush brushAboutBg = CreateSolidBrush(col);
FillRect(hdc, &rTmp, brushAboutBg);

col = gCurrentTheme->window.textColor;
Expand Down
2 changes: 1 addition & 1 deletion src/wingui/FrameRateWnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ that it's actually a part of that window.

static void FrameRatePaint(FrameRateWnd* w, HDC hdc, PAINTSTRUCT&) {
RECT rc = ClientRECT(w->hwnd);
ScopedGdiObj<HBRUSH> brush(CreateSolidBrush(COL_BLACK));
AutoDeleteBrush brush = CreateSolidBrush(COL_BLACK);
FillRect(hdc, &rc, brush);

SetTextColor(hdc, COL_WHITE);
Expand Down

0 comments on commit 65f12cc

Please sign in to comment.