mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-24 06:14:47 +02:00
Fix URL Link controls color in dark mode consistent issue for plugins
Fix #16537, close #16538
This commit is contained in:
parent
f677a0c5db
commit
3310a613e4
@ -2637,6 +2637,19 @@ namespace NppDarkMode
|
||||
return false;
|
||||
}
|
||||
|
||||
static void setUrlLinkControlColor(HWND hWnd, NppDarkModeParams p)
|
||||
{
|
||||
if (p._theme)
|
||||
{
|
||||
LITEM item{};
|
||||
item.iLink = 0; // for now colorize only 1st item
|
||||
item.mask = LIF_ITEMINDEX | LIF_STATE;
|
||||
item.state = NppDarkMode::isEnabled() ? LIS_DEFAULTCOLORS : 0;
|
||||
item.stateMask = LIS_DEFAULTCOLORS;
|
||||
::SendMessage(hWnd, LM_SETITEM, 0, reinterpret_cast<LPARAM>(&item));
|
||||
}
|
||||
}
|
||||
|
||||
void autoSubclassAndThemeChildControls(HWND hwndParent, bool subclass, bool theme)
|
||||
{
|
||||
NppDarkModeParams p{
|
||||
@ -2715,6 +2728,13 @@ namespace NppDarkMode
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// For plugins: Prep SysLink so that colors can be set later in WM_CTLCOLORSTATIC
|
||||
if (wcscmp(className, WC_LINK) == 0)
|
||||
{
|
||||
NppDarkMode::setUrlLinkControlColor(hwnd, p);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
// for debugging
|
||||
if (wcscmp(className, L"#32770") == 0)
|
||||
@ -3373,15 +3393,27 @@ namespace NppDarkMode
|
||||
{
|
||||
if (NppDarkMode::isEnabled())
|
||||
{
|
||||
constexpr size_t classNameLen = 16;
|
||||
wchar_t className[classNameLen]{};
|
||||
auto hwndEdit = reinterpret_cast<HWND>(lParam);
|
||||
GetClassName(hwndEdit, className, classNameLen);
|
||||
if (wcscmp(className, WC_EDIT) == 0)
|
||||
auto hChild = reinterpret_cast<HWND>(lParam);
|
||||
const bool isChildEnabled = ::IsWindowEnabled(hChild) == TRUE;
|
||||
std::wstring className = getWndClassName(hChild);
|
||||
|
||||
auto hdc = reinterpret_cast<HDC>(wParam);
|
||||
|
||||
if (className == WC_EDIT)
|
||||
{
|
||||
return NppDarkMode::onCtlColor(reinterpret_cast<HDC>(wParam));
|
||||
if (isChildEnabled)
|
||||
{
|
||||
return NppDarkMode::onCtlColor(hdc);
|
||||
}
|
||||
return NppDarkMode::onCtlColorDlg(reinterpret_cast<HDC>(wParam));
|
||||
return NppDarkMode::onCtlColorDlg(hdc);
|
||||
}
|
||||
|
||||
if (className == WC_LINK)
|
||||
{
|
||||
return NppDarkMode::onCtlColorDlgLinkText(hdc, isChildEnabled);
|
||||
}
|
||||
|
||||
return NppDarkMode::onCtlColorDlg(hdc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user