Fix GDI leak in setStartupBgColor

- remove unneeded icon color constants

Fix #16442, close #16443
This commit is contained in:
ozone10 2025-04-18 19:14:50 +02:00 committed by Don Ho
parent 4ddad4683b
commit 9f2326d30c
2 changed files with 7 additions and 11 deletions

View File

@ -54,12 +54,13 @@ void Notepad_plus_Window::setStartupBgColor(COLORREF BgColor)
RECT windowClientArea; RECT windowClientArea;
HDC hdc = GetDCEx(_hSelf, NULL, DCX_CACHE | DCX_LOCKWINDOWUPDATE); //lock window update flag due to PaintLocker HDC hdc = GetDCEx(_hSelf, NULL, DCX_CACHE | DCX_LOCKWINDOWUPDATE); //lock window update flag due to PaintLocker
GetClientRect(_hSelf, &windowClientArea); GetClientRect(_hSelf, &windowClientArea);
FillRect(hdc, &windowClientArea, CreateSolidBrush(BgColor)); HBRUSH hBrush = ::CreateSolidBrush(BgColor);
::FillRect(hdc, &windowClientArea, hBrush);
::DeleteObject(hBrush);
ReleaseDC(_hSelf, hdc); ReleaseDC(_hSelf, hdc);
} }
void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const wchar_t *cmdLine, CmdLineParams *cmdLineParams) void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const wchar_t *cmdLine, CmdLineParams *cmdLineParams)
{ {
Window::init(hInst, parent); Window::init(hInst, parent);

View File

@ -392,13 +392,8 @@ namespace NppDarkMode
return opt; return opt;
} }
constexpr COLORREF cDefaultMainDark = RGB(0xDE, 0xDE, 0xDE); static COLORREF cAccentDark = g_cDefaultSecondaryDark;
constexpr COLORREF cDefaultSecondaryDark = RGB(0x4C, 0xC2, 0xFF); static COLORREF cAccentLight = g_cDefaultSecondaryLight;
constexpr COLORREF cDefaultMainLight = RGB(0x21, 0x21, 0x21);
constexpr COLORREF cDefaultSecondaryLight = RGB(0x00, 0x78, 0xD4);
static COLORREF cAccentDark = cDefaultSecondaryDark;
static COLORREF cAccentLight = cDefaultSecondaryLight;
static COLORREF adjustClrLightness(COLORREF clr, bool useDark) static COLORREF adjustClrLightness(COLORREF clr, bool useDark)
{ {
@ -436,8 +431,8 @@ namespace NppDarkMode
return true; return true;
} }
cAccentDark = cDefaultSecondaryDark; cAccentDark = g_cDefaultSecondaryDark;
cAccentLight = cDefaultSecondaryLight; cAccentLight = g_cDefaultSecondaryLight;
return false; return false;
} }