From 3167752f109a654e7454283f130080f0b3f9bb94 Mon Sep 17 00:00:00 2001 From: lx-s Date: Wed, 8 Jul 2026 10:40:26 +0200 Subject: [PATCH] use fixed brush to avoid leak --- WinMute/WinMute.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/WinMute/WinMute.cpp b/WinMute/WinMute.cpp index 37b75e2..feb6c6d 100644 --- a/WinMute/WinMute.cpp +++ b/WinMute/WinMute.cpp @@ -128,7 +128,8 @@ bool WinMute::RegisterWindowClass() WNDCLASSEX wc = { 0 }; wc.cbSize = sizeof(wc); wc.hIcon = LoadIcon(hglobInstance, MAKEINTRESOURCE(IDI_APP)); - wc.hbrBackground = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); + // System color index brush: no GDI object to leak, tracks theme changes + wc.hbrBackground = reinterpret_cast(COLOR_BTNFACE + 1); wc.hInstance = hglobInstance; wc.lpfnWndProc = WinMuteWndProc; wc.lpszClassName = WINMUTE_CLASS_NAME; @@ -243,12 +244,12 @@ bool WinMute::Init() hTrayIcon_ = LoadIconW(hglobInstance, MAKEINTRESOURCE(IDI_APP)); if (hTrayIcon_ == nullptr) { - ShowWindowsError(_T("LoadIcon")); + ShowWindowsError(L"LoadIcon"); return false; } hUpdateIcon_ = LoadIconW(hglobInstance, MAKEINTRESOURCE(IDI_APPUPDATE)); if (hUpdateIcon_ == nullptr) { - ShowWindowsError(_T("LoadIcon")); + ShowWindowsError(L"LoadIcon"); return false; } wmTray_.Init(hWnd_, 0, hTrayIcon_, L"WinMute", true); -- 2.43.0