From 65f12ccc0c7ca0db18449c2a69ca894d2c412c36 Mon Sep 17 00:00:00 2001 From: Krzysztof Kowalczyk Date: Sat, 28 Oct 2023 23:54:53 +0200 Subject: [PATCH] use AutoDeleteBrush some more --- src/Canvas.cpp | 10 +++++----- src/HomePage.cpp | 6 +++--- src/SumatraProperties.cpp | 2 +- src/wingui/FrameRateWnd.cpp | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Canvas.cpp b/src/Canvas.cpp index 4b67e0c18643..61081e752d08 100644 --- a/src/Canvas.cpp +++ b/src/Canvas.cpp @@ -759,13 +759,13 @@ static void PaintPageFrameAndShadow(HDC hdc, Rect& bounds, Rect& pageRect, bool // Draw shadow if (!presentation) { - ScopedGdiObj brush(CreateSolidBrush(COL_PAGE_SHADOW)); + AutoDeleteBrush brush = CreateSolidBrush(COL_PAGE_SHADOW); FillRect(hdc, &shadow.ToRECT(), brush); } // Draw frame ScopedGdiObj pe(CreatePen(PS_SOLID, 1, presentation ? TRANSPARENT : COL_PAGE_FRAME)); - ScopedGdiObj 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); @@ -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 brush(CreateSolidBrush(WIN_COL_BLACK)); + AutoDeleteBrush brush = CreateSolidBrush(WIN_COL_BLACK); FillRect(hdc, rcArea, brush); } else if (0 == nGCols) { auto col = GetMainWindowBackgroundColor(); - ScopedGdiObj brush(CreateSolidBrush(col)); + AutoDeleteBrush brush = CreateSolidBrush(col); FillRect(hdc, rcArea, brush); } else { COLORREF colors[3]; @@ -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 bgBrush(CreateSolidBrush(bgCol)); + AutoDeleteBrush bgBrush = CreateSolidBrush(bgCol); FillRect(hdc, &ps.rcPaint, bgBrush); // TODO: should this be "Error opening %s"? auto tab = win->CurrentTab(); diff --git a/src/HomePage.cpp b/src/HomePage.cpp index 1b92b36f55c5..0b9f0943dacc 100644 --- a/src/HomePage.cpp +++ b/src/HomePage.cpp @@ -300,13 +300,13 @@ static void DrawAbout(HWND hwnd, HDC hdc, Rect rect, Vec& stati Rect rc = ClientRect(hwnd); RECT rTmp = ToRECT(rc); col = GetMainWindowBackgroundColor(); - ScopedGdiObj 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 @@ -724,7 +724,7 @@ void DrawHomePage(MainWindow* win, HDC hdc, FileHistory& fileHistory, COLORREF t rc.dy -= titleBox.dy; rTmp = ToRECT(rc); col = GetMainWindowBackgroundColor(); - ScopedGdiObj brushAboutBg(CreateSolidBrush(col)); + AutoDeleteBrush brushAboutBg = CreateSolidBrush(col); FillRect(hdc, &rTmp, brushAboutBg); rc.dy -= kDocListBottomBoxDy; diff --git a/src/SumatraProperties.cpp b/src/SumatraProperties.cpp index 17f929ce725f..9a27e2aad154 100644 --- a/src/SumatraProperties.cpp +++ b/src/SumatraProperties.cpp @@ -602,7 +602,7 @@ static void DrawProperties(HWND hwnd, HDC hdc) { Rect rcClient = ClientRect(hwnd); RECT rTmp = ToRECT(rcClient); auto col = GetMainWindowBackgroundColor(); - ScopedGdiObj brushAboutBg(CreateSolidBrush(col)); + AutoDeleteBrush brushAboutBg = CreateSolidBrush(col); FillRect(hdc, &rTmp, brushAboutBg); col = gCurrentTheme->window.textColor; diff --git a/src/wingui/FrameRateWnd.cpp b/src/wingui/FrameRateWnd.cpp index 2e3d81c556fd..44ec82f9c630 100755 --- a/src/wingui/FrameRateWnd.cpp +++ b/src/wingui/FrameRateWnd.cpp @@ -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 brush(CreateSolidBrush(COL_BLACK)); + AutoDeleteBrush brush = CreateSolidBrush(COL_BLACK); FillRect(hdc, &rc, brush); SetTextColor(hdc, COL_WHITE);