Skip to content

Commit

Permalink
Progress window: Prefer SystemParametersInfo fonts over DEFAULT_GUI_FONT
Browse files Browse the repository at this point in the history
Fix #13764
  • Loading branch information
ozone10 authored and donho committed Jun 11, 2023
1 parent da8e48f commit 28594da
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
26 changes: 19 additions & 7 deletions PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp
Expand Up @@ -5564,6 +5564,12 @@ void Progress::close()
::CloseHandle(_hThread);
::CloseHandle(_hActiveState);
}

if (_hFont != nullptr)
{
::DeleteObject(_hFont);
_hFont = nullptr;
}
}


Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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)
{
LOGFONT lf{ NppParameters::getDefaultGUIFont() };
_hFont = ::CreateFontIndirect(&lf);
}

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));
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);
Expand Down
1 change: 1 addition & 0 deletions PowerEditor/src/ScintillaComponent/FindReplaceDlg.h
Expand Up @@ -600,5 +600,6 @@ class Progress
HWND _hRunningHitsText = nullptr;
HWND _hPBar = nullptr;
HWND _hBtn = nullptr;
HFONT _hFont = nullptr;
};

0 comments on commit 28594da

Please sign in to comment.