Progress window: Prefer SystemParametersInfo fonts over DEFAULT_GUI_FONT

Fix #13764
This commit is contained in:
ozone10 2023-06-11 10:17:53 +02:00 committed by Don Ho
parent da8e48f67a
commit 28594daef3
2 changed files with 20 additions and 7 deletions

View File

@ -5564,6 +5564,12 @@ void Progress::close()
::CloseHandle(_hThread);
::CloseHandle(_hActiveState);
}
if (_hFont != nullptr)
{
::DeleteObject(_hFont);
_hFont = nullptr;
}
}
@ -5676,7 +5682,7 @@ int Progress::createProgressWindow()
_hRunningHitsText = ::CreateWindowEx(0, TEXT("STATIC"), TEXT(""),
WS_CHILD | WS_VISIBLE,
xStartPos + 75 + 2, yTextPos + textHeight * 2,
70, textHeight,
dpiManager.scaleX(70), textHeight,
_hwnd, NULL, _hInst, NULL);
_hPBar = ::CreateWindowEx(0, PROGRESS_CLASS, TEXT("Progress Bar"),
@ -5705,13 +5711,19 @@ int Progress::createProgressWindow()
cBTNwidth, cBTNheight,
_hwnd, NULL, _hInst, NULL);
HFONT hf = (HFONT)::GetStockObject(DEFAULT_GUI_FONT);
if (hf)
if (_hFont == nullptr)
{
::SendMessage(_hPathText, WM_SETFONT, reinterpret_cast<WPARAM>(hf), MAKELPARAM(TRUE, 0));
::SendMessage(_hRunningHitsStaticText, WM_SETFONT, reinterpret_cast<WPARAM>(hf), MAKELPARAM(TRUE, 0));
::SendMessage(_hRunningHitsText, WM_SETFONT, reinterpret_cast<WPARAM>(hf), MAKELPARAM(TRUE, 0));
::SendMessage(_hBtn, WM_SETFONT, reinterpret_cast<WPARAM>(hf), MAKELPARAM(TRUE, 0));
LOGFONT lf{ NppParameters::getDefaultGUIFont() };
_hFont = ::CreateFontIndirect(&lf);
}
if (_hFont != nullptr)
{
const auto& wpFont = reinterpret_cast<WPARAM>(_hFont);
::SendMessage(_hPathText, WM_SETFONT, wpFont, TRUE);
::SendMessage(_hRunningHitsStaticText, WM_SETFONT, wpFont, TRUE);
::SendMessage(_hRunningHitsText, WM_SETFONT, wpFont, TRUE);
::SendMessage(_hBtn, WM_SETFONT, wpFont, TRUE);
}
NppDarkMode::autoSubclassAndThemeChildControls(_hwnd);

View File

@ -600,5 +600,6 @@ private:
HWND _hRunningHitsText = nullptr;
HWND _hPBar = nullptr;
HWND _hBtn = nullptr;
HFONT _hFont = nullptr;
};