mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-17 21:03:19 +08:00
+ add: Menu item to switch between Default and Dark-Mode
This commit is contained in:
parent
3fa8c283dd
commit
8f08a843b6
@ -675,6 +675,7 @@
|
||||
#define IDM_VIEW_EDIT_LINECOMMENT 40483
|
||||
#define IDM_VIEW_EVALTINYEXPRONSEL 40484
|
||||
#define IDM_VIEW_UNICODE_POINTS 40485
|
||||
#define IDM_VIEW_WIN_DARK_MODE 40486
|
||||
|
||||
// keep Scintilla(SC) order
|
||||
#define IDM_SET_RENDER_TECH_GDI 40500 // SC_TECHNOLOGY_DEFAULT(0)
|
||||
|
||||
@ -430,6 +430,8 @@ BEGIN
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Globaler &Standard Font...\tAlt+F12", IDM_VIEW_FONT
|
||||
MENUITEM "Aktueller Schema Font...\tCtrl+Alt+F12", IDM_VIEW_CURRENTSCHEME
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Windows Dunkler Modus", IDM_VIEW_WIN_DARK_MODE
|
||||
END
|
||||
POPUP "&Einstellungen"
|
||||
BEGIN
|
||||
|
||||
@ -430,6 +430,8 @@ BEGIN
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Global &Default Font...\tAlt+F12", IDM_VIEW_FONT
|
||||
MENUITEM "Current Sc&heme's Default Font...\tCtrl+Alt+F12", IDM_VIEW_CURRENTSCHEME
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Windows Dark Mode", IDM_VIEW_WIN_DARK_MODE
|
||||
END
|
||||
POPUP "&Settings"
|
||||
BEGIN
|
||||
|
||||
@ -1472,6 +1472,7 @@ void LoadSettings()
|
||||
GET_BOOL_VALUE_FROM_INISECTION(SplitUndoTypingSeqOnLnBreak, true);
|
||||
GET_BOOL_VALUE_FROM_INISECTION(EditLayoutRTL, false);
|
||||
GET_BOOL_VALUE_FROM_INISECTION(DialogsLayoutRTL, false);
|
||||
GET_BOOL_VALUE_FROM_INISECTION(WinThemeDarkMode, true);
|
||||
|
||||
///~Settings2.IMEInteraction = clampi(IniSectionGetInt(IniSecSettings, L"IMEInteraction", Settings2.IMEInteraction), SC_IME_WINDOWED, SC_IME_INLINE);
|
||||
|
||||
@ -1914,6 +1915,7 @@ static bool _SaveSettings(bool bForceSaveSettings)
|
||||
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, SplitUndoTypingSeqOnLnBreak);
|
||||
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, EditLayoutRTL);
|
||||
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, DialogsLayoutRTL);
|
||||
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, WinThemeDarkMode);
|
||||
|
||||
///~IniSectionSetInt(IniSecSettings, L"IMEInteraction", Settings2.IMEInteraction);
|
||||
|
||||
|
||||
@ -2753,7 +2753,7 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::Save(
|
||||
if (iSection->pComment) {
|
||||
if (bNeedNewLine) {
|
||||
a_oOutput.Write(SI_NEWLINE_A);
|
||||
//§§§a_oOutput.Write(SI_NEWLINE_A);
|
||||
//???a_oOutput.Write(SI_NEWLINE_A);
|
||||
bNeedNewLine = false;
|
||||
}
|
||||
if (!OutputMultiLineText(a_oOutput, convert, iSection->pComment)) {
|
||||
@ -2763,7 +2763,7 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::Save(
|
||||
|
||||
if (bNeedNewLine) {
|
||||
a_oOutput.Write(SI_NEWLINE_A);
|
||||
//§§§a_oOutput.Write(SI_NEWLINE_A);
|
||||
//???a_oOutput.Write(SI_NEWLINE_A);
|
||||
bNeedNewLine = false;
|
||||
}
|
||||
|
||||
@ -2839,7 +2839,7 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::Save(
|
||||
bNeedNewLine = false;
|
||||
}
|
||||
}
|
||||
//§§§bNeedNewLine = true;
|
||||
//???bNeedNewLine = true;
|
||||
}
|
||||
|
||||
return SI_Error::SI_OK;
|
||||
|
||||
@ -48,105 +48,6 @@ extern "C" DWORD GetWindowsBuildNumber(LPDWORD major, LPDWORD minor)
|
||||
}
|
||||
// ============================================================================
|
||||
|
||||
#if FALSE
|
||||
//=============================================================================
|
||||
//
|
||||
// OwnerDrawItem() - Handles WM_DRAWITEM
|
||||
// https://docs.microsoft.com/en-us/windows/win32/controls/status-bars#owner-drawn-status-bars
|
||||
//
|
||||
extern "C" LRESULT OwnerDrawTextItem(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
(void)(hwnd);
|
||||
(void)(wParam); // sender control
|
||||
|
||||
const DRAWITEMSTRUCT *const pDIS = (const DRAWITEMSTRUCT *const)lParam;
|
||||
|
||||
//UINT const ctlId = pDIS->CtlID;
|
||||
//int const partId = (int)pDIS->itemID;
|
||||
//int const stateId = (int)pDIS->itemState;
|
||||
//LPCWSTR const data = (LPCWSTR)(pDIS->itemData);
|
||||
|
||||
//~PAINTSTRUCT ps;
|
||||
//~BeginPaint(hWndItem, &ps); ~ not needed on WM_DRAWITEM
|
||||
|
||||
HDC const hdc = pDIS->hDC;
|
||||
|
||||
#ifdef D_NP3_WIN10_DARK_MODE
|
||||
//HTHEME const hTheme = OpenThemeData(hWndSB, L"BUTTON");
|
||||
//if (hTheme) {
|
||||
SetBkColor(hdc, UseDarkMode() ? g_rgbDarkBkgColor : GetSysColor(COLOR_BTNFACE));
|
||||
//DrawEdge(hdc, &rc, EDGE_RAISED, BF_RECT);
|
||||
//DrawThemeEdge(hTheme, hdc, partId, stateId, &rc, EDGE_RAISED, BF_RECT, NULL);
|
||||
SetTextColor(hdc, UseDarkMode() ? g_rgbDarkTextColor : GetSysColor(COLOR_BTNTEXT));
|
||||
// CloseThemeData(hTheme);
|
||||
//}
|
||||
#else
|
||||
SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
|
||||
SetTextColor(hdc, GetSysColor(COLOR_BTNTEXT));
|
||||
#endif
|
||||
|
||||
WCHAR text[256] = { L'\0' };
|
||||
HWND const hWndItem = pDIS->hwndItem;
|
||||
int const len = (int)SendMessage(hWndItem, WM_GETTEXT, ARRAYSIZE(text), (LPARAM)text);
|
||||
|
||||
RECT rc = pDIS->rcItem;
|
||||
ExtTextOut(hdc, rc.left + 2, rc.top + 2, ETO_OPAQUE | ETO_NUMERICSLOCAL, &rc, text, len, NULL);
|
||||
|
||||
//~EndPaint(hWndItem, &ps);
|
||||
return TRUE;
|
||||
}
|
||||
// ============================================================================
|
||||
#endif
|
||||
|
||||
|
||||
#if FALSE
|
||||
//=============================================================================
|
||||
//
|
||||
// OwnerDrawItem() - Handles WM_DRAWITEM
|
||||
// https://docs.microsoft.com/en-us/windows/win32/controls/status-bars#owner-drawn-status-bars
|
||||
//
|
||||
extern "C" LRESULT OwnerDrawTextItem(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
(void)(hwnd);
|
||||
(void)(wParam); // sender control
|
||||
|
||||
const DRAWITEMSTRUCT *const pDIS = (const DRAWITEMSTRUCT *const)lParam;
|
||||
|
||||
//UINT const ctlId = pDIS->CtlID;
|
||||
//LPCWSTR const data = (LPCWSTR)(pDIS->itemData);
|
||||
|
||||
//~PAINTSTRUCT ps;
|
||||
//~BeginPaint(hWndItem, &ps); ~ not needed on WM_DRAWITEM
|
||||
|
||||
HWND const hwndButton = pDIS->hwndItem;
|
||||
HTHEME const hTheme = OpenThemeData(hwndButton, L"Button");
|
||||
if (hTheme) {
|
||||
RECT rc;
|
||||
GetWindowRect(hwndButton, &rc);
|
||||
|
||||
HDC const hdc = pDIS->hDC;
|
||||
int const partId = BS_AUTORADIOBUTTON; // (int)pDIS->partID;
|
||||
int const stateId = BST_UNCHECKED; // (int)pDIS->itemState;
|
||||
HRESULT hr = DrawThemeBackground(hTheme, hdc, partId, stateId, &rc, 0);
|
||||
RECT rcContent = { 0 };
|
||||
if (SUCCEEDED(hr)) {
|
||||
hr = GetThemeBackgroundContentRect(hTheme, hdc, partId, stateId, &rc, &rcContent);
|
||||
}
|
||||
if (SUCCEEDED(hr)) {
|
||||
WCHAR szButtonText[255];
|
||||
int const len = GetWindowText(hwndButton, szButtonText, ARRAYSIZE(szButtonText));
|
||||
hr = DrawThemeText(hTheme, hdc, partId, stateId, szButtonText, len, DT_LEFT | DT_VCENTER | DT_SINGLELINE, 0, &rcContent);
|
||||
}
|
||||
CloseThemeData(hTheme);
|
||||
//~EndPaint(hWndItem, &ps);
|
||||
return SUCCEEDED(hr);
|
||||
}
|
||||
//~EndPaint(hWndItem, &ps);
|
||||
return FALSE;
|
||||
}
|
||||
// ============================================================================
|
||||
#endif
|
||||
|
||||
#ifdef D_NP3_WIN10_DARK_MODE
|
||||
|
||||
#pragma comment(lib, "Comctl32.lib")
|
||||
@ -242,16 +143,20 @@ fnSetPreferredAppMode _SetPreferredAppMode = nullptr;
|
||||
|
||||
|
||||
static bool s_bDarkModeSupported = false;
|
||||
|
||||
extern "C" bool IsDarkModeSupported() {
|
||||
return s_bDarkModeSupported;
|
||||
}
|
||||
// ============================================================================
|
||||
|
||||
|
||||
static bool s_bDarkModeEnabled = false;
|
||||
static bool s_UserDisabled = true;
|
||||
|
||||
extern "C" bool CheckDarkModeEnabled() {
|
||||
s_bDarkModeEnabled = _ShouldAppsUseDarkMode() && !IsHighContrast();
|
||||
return s_bDarkModeEnabled;
|
||||
if (_ShouldAppsUseDarkMode) {
|
||||
return !s_UserDisabled && _ShouldAppsUseDarkMode() && !IsHighContrast();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// ============================================================================
|
||||
|
||||
@ -325,7 +230,7 @@ extern "C" void AllowDarkModeForApp(bool allow)
|
||||
// ============================================================================
|
||||
|
||||
|
||||
static void _FixDarkScrollBar()
|
||||
static void _FixDarkScrollBar(bool bDarkMode)
|
||||
{
|
||||
HMODULE hComctl = LoadLibraryExW(L"comctl32.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
|
||||
if (hComctl) {
|
||||
@ -340,7 +245,10 @@ static void _FixDarkScrollBar()
|
||||
}
|
||||
return _OpenNcThemeData(hWnd, classList);
|
||||
};
|
||||
addr->u1.Function = reinterpret_cast<ULONG_PTR>(static_cast<fnOpenNcThemeData>(MyOpenThemeData));
|
||||
if (bDarkMode)
|
||||
addr->u1.Function = reinterpret_cast<ULONG_PTR>(static_cast<fnOpenNcThemeData>(MyOpenThemeData));
|
||||
else
|
||||
addr->u1.Function = reinterpret_cast<ULONG_PTR>(_OpenNcThemeData);
|
||||
VirtualProtect(addr, sizeof(IMAGE_THUNK_DATA), oldProtect, &oldProtect);
|
||||
}
|
||||
}
|
||||
@ -349,32 +257,8 @@ static void _FixDarkScrollBar()
|
||||
// ============================================================================
|
||||
|
||||
|
||||
constexpr COLORREF GetDarkBkgColor() {
|
||||
// gets old Win32 colors :-(
|
||||
//if (IsAppThemed()) {
|
||||
// HTHEME const hTheme = OpenThemeData(NULL, L"WINDOWSTYLE;WINDOW");
|
||||
// if (hTheme) {
|
||||
// COLORREF const color = GetThemeSysColor(hTheme, COLOR_WINDOW);
|
||||
// CloseThemeData(hTheme);
|
||||
// return color;
|
||||
// }
|
||||
//}
|
||||
return RGB(0x38,0x38,0x38);
|
||||
}
|
||||
|
||||
constexpr COLORREF GetDarkTextColor() {
|
||||
// gets old Win32 colors :-(
|
||||
//if (IsAppThemed()) {
|
||||
// HTHEME const hTheme = OpenThemeData(NULL, L"WINDOWSTYLE;WINDOW");
|
||||
// if (hTheme) {
|
||||
// COLORREF const color = GetThemeSysColor(hTheme, COLOR_WINDOWTEXT);
|
||||
// CloseThemeData(hTheme);
|
||||
// return color;
|
||||
// }
|
||||
//}
|
||||
return RGB(0xEF, 0xEF, 0xEF);
|
||||
}
|
||||
|
||||
constexpr COLORREF GetDarkBkgColor() { return RGB(0x38,0x38,0x38); }
|
||||
constexpr COLORREF GetDarkTextColor() { return RGB(0xEF, 0xEF, 0xEF); }
|
||||
|
||||
constexpr bool CheckBuildNumber(DWORD buildNumber) {
|
||||
return (buildNumber == 17763 || // 1809
|
||||
@ -383,11 +267,14 @@ constexpr bool CheckBuildNumber(DWORD buildNumber) {
|
||||
buildNumber == 19041); // 2004
|
||||
}
|
||||
|
||||
extern "C" void InitDarkMode(bool bEnableDarkMode)
|
||||
{
|
||||
g_rgbDarkBkgColor = bEnableDarkMode ? GetDarkBkgColor() : GetSysColor(COLOR_WINDOW);
|
||||
g_rgbDarkTextColor = bEnableDarkMode ? GetDarkTextColor() : GetSysColor(COLOR_WINDOWTEXT);
|
||||
|
||||
extern "C" void InitDarkMode()
|
||||
{
|
||||
g_rgbDarkBkgColor = GetDarkBkgColor();
|
||||
g_rgbDarkTextColor = GetDarkTextColor();
|
||||
if (g_hbrWndDarkBkgBrush) {
|
||||
DeleteObject(g_hbrWndDarkBkgBrush);
|
||||
}
|
||||
g_hbrWndDarkBkgBrush = CreateSolidBrush(g_rgbDarkBkgColor);
|
||||
|
||||
DWORD major, minor;
|
||||
@ -399,40 +286,61 @@ extern "C" void InitDarkMode()
|
||||
HMODULE const hUxtheme = LoadLibraryExW(L"uxtheme.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
|
||||
if (hUxtheme)
|
||||
{
|
||||
_OpenNcThemeData = reinterpret_cast<fnOpenNcThemeData>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(49)));
|
||||
_RefreshImmersiveColorPolicyState = reinterpret_cast<fnRefreshImmersiveColorPolicyState>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(104)));
|
||||
_GetIsImmersiveColorUsingHighContrast = reinterpret_cast<fnGetIsImmersiveColorUsingHighContrast>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(106)));
|
||||
_ShouldAppsUseDarkMode = reinterpret_cast<fnShouldAppsUseDarkMode>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(132)));
|
||||
_AllowDarkModeForWindow = reinterpret_cast<fnAllowDarkModeForWindow>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(133)));
|
||||
if (!_OpenNcThemeData) {
|
||||
_OpenNcThemeData = reinterpret_cast<fnOpenNcThemeData>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(49)));
|
||||
}
|
||||
if (!_RefreshImmersiveColorPolicyState) {
|
||||
_RefreshImmersiveColorPolicyState = reinterpret_cast<fnRefreshImmersiveColorPolicyState>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(104)));
|
||||
}
|
||||
if (!_GetIsImmersiveColorUsingHighContrast) {
|
||||
_GetIsImmersiveColorUsingHighContrast = reinterpret_cast<fnGetIsImmersiveColorUsingHighContrast>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(106)));
|
||||
}
|
||||
if (!_ShouldAppsUseDarkMode) {
|
||||
_ShouldAppsUseDarkMode = reinterpret_cast<fnShouldAppsUseDarkMode>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(132)));
|
||||
}
|
||||
if (!_AllowDarkModeForWindow) {
|
||||
_AllowDarkModeForWindow = reinterpret_cast<fnAllowDarkModeForWindow>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(133)));
|
||||
}
|
||||
|
||||
auto const ord135 = GetProcAddress(hUxtheme, MAKEINTRESOURCEA(135));
|
||||
if (buildNumber < 18334)
|
||||
_AllowDarkModeForApp = reinterpret_cast<fnAllowDarkModeForApp>(ord135);
|
||||
else
|
||||
_SetPreferredAppMode = reinterpret_cast<fnSetPreferredAppMode>(ord135);
|
||||
if (buildNumber < 18334) {
|
||||
if (!_AllowDarkModeForApp) {
|
||||
_AllowDarkModeForApp = reinterpret_cast<fnAllowDarkModeForApp>(ord135);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!_SetPreferredAppMode) {
|
||||
_SetPreferredAppMode = reinterpret_cast<fnSetPreferredAppMode>(ord135);
|
||||
}
|
||||
}
|
||||
|
||||
//_FlushMenuThemes = reinterpret_cast<fnFlushMenuThemes>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(136)));
|
||||
_IsDarkModeAllowedForWindow = reinterpret_cast<fnIsDarkModeAllowedForWindow>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(137)));
|
||||
|
||||
_SetWindowCompositionAttribute = reinterpret_cast<fnSetWindowCompositionAttribute>(GetProcAddress(GetModuleHandleW(L"user32.dll"), "SetWindowCompositionAttribute"));
|
||||
if (!_FlushMenuThemes) {
|
||||
_FlushMenuThemes = reinterpret_cast<fnFlushMenuThemes>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(136)));
|
||||
}
|
||||
if (!_IsDarkModeAllowedForWindow) {
|
||||
_IsDarkModeAllowedForWindow = reinterpret_cast<fnIsDarkModeAllowedForWindow>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(137)));
|
||||
}
|
||||
if (!_SetWindowCompositionAttribute) {
|
||||
HMODULE const hModuleUSR32DLL = GetModuleHandleW(L"user32.dll");
|
||||
if (hModuleUSR32DLL) {
|
||||
_SetWindowCompositionAttribute = reinterpret_cast<fnSetWindowCompositionAttribute>(GetProcAddress(hModuleUSR32DLL, "SetWindowCompositionAttribute"));
|
||||
}
|
||||
}
|
||||
|
||||
if (_OpenNcThemeData &&
|
||||
_RefreshImmersiveColorPolicyState &&
|
||||
_ShouldAppsUseDarkMode &&
|
||||
_AllowDarkModeForWindow &&
|
||||
(_AllowDarkModeForApp || _SetPreferredAppMode) &&
|
||||
//_FlushMenuThemes &&
|
||||
_FlushMenuThemes &&
|
||||
_IsDarkModeAllowedForWindow)
|
||||
{
|
||||
s_bDarkModeSupported = true;
|
||||
|
||||
AllowDarkModeForApp(true);
|
||||
|
||||
s_UserDisabled = !bEnableDarkMode;
|
||||
AllowDarkModeForApp(bEnableDarkMode);
|
||||
_RefreshImmersiveColorPolicyState();
|
||||
|
||||
s_bDarkModeSupported = _ShouldAppsUseDarkMode() && !IsHighContrast();
|
||||
|
||||
_FixDarkScrollBar();
|
||||
s_bDarkModeSupported = _ShouldAppsUseDarkMode() && !IsHighContrast(); // (!) after _RefreshImmersiveColorPolicyState()
|
||||
_FlushMenuThemes();
|
||||
_FixDarkScrollBar(bEnableDarkMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -442,9 +350,14 @@ extern "C" void InitDarkMode()
|
||||
|
||||
#else // NO DarkMode support
|
||||
|
||||
extern "C" void InitDarkMode() {
|
||||
g_rgbDarkBkgColor = GetSysColor(COLOR_WINDOW);
|
||||
g_rgbDarkTextColor = GetSysColor(COLOR_WINDOWTEXT);
|
||||
extern "C" void InitDarkMode(bool bEnableDarkMode)
|
||||
{
|
||||
g_rgbDarkBkgColor = bEnableDarkMode ? GetDarkBkgColor() : GetSysColor(COLOR_WINDOW);
|
||||
g_rgbDarkTextColor = bEnableDarkMode ? GetDarkTextColor() : GetSysColor(COLOR_WINDOWTEXT);
|
||||
|
||||
if (g_hbrWndDarkBkgBrush) {
|
||||
DeleteObject(g_hbrWndDarkBkgBrush);
|
||||
}
|
||||
g_hbrWndDarkBkgBrush = CreateSolidBrush(g_rgbDarkBkgColor);
|
||||
}
|
||||
|
||||
@ -458,3 +371,100 @@ extern "C" void ReleaseDarkMode() {
|
||||
|
||||
// ============================================================================
|
||||
|
||||
|
||||
#if FALSE
|
||||
//=============================================================================
|
||||
//
|
||||
// OwnerDrawItem() - Handles WM_DRAWITEM
|
||||
// https://docs.microsoft.com/en-us/windows/win32/controls/status-bars#owner-drawn-status-bars
|
||||
//
|
||||
extern "C" LRESULT OwnerDrawTextItem(HWND hwnd, WPARAM wParam, LPARAM lParam) {
|
||||
(void)(hwnd);
|
||||
(void)(wParam); // sender control
|
||||
|
||||
const DRAWITEMSTRUCT *const pDIS = (const DRAWITEMSTRUCT *const)lParam;
|
||||
|
||||
//UINT const ctlId = pDIS->CtlID;
|
||||
//int const partId = (int)pDIS->itemID;
|
||||
//int const stateId = (int)pDIS->itemState;
|
||||
//LPCWSTR const data = (LPCWSTR)(pDIS->itemData);
|
||||
|
||||
//~PAINTSTRUCT ps;
|
||||
//~BeginPaint(hWndItem, &ps); ~ not needed on WM_DRAWITEM
|
||||
|
||||
HDC const hdc = pDIS->hDC;
|
||||
|
||||
#ifdef D_NP3_WIN10_DARK_MODE
|
||||
//HTHEME const hTheme = OpenThemeData(hWndSB, L"BUTTON");
|
||||
//if (hTheme) {
|
||||
SetBkColor(hdc, UseDarkMode() ? g_rgbDarkBkgColor : GetSysColor(COLOR_BTNFACE));
|
||||
//DrawEdge(hdc, &rc, EDGE_RAISED, BF_RECT);
|
||||
//DrawThemeEdge(hTheme, hdc, partId, stateId, &rc, EDGE_RAISED, BF_RECT, NULL);
|
||||
SetTextColor(hdc, UseDarkMode() ? g_rgbDarkTextColor : GetSysColor(COLOR_BTNTEXT));
|
||||
// CloseThemeData(hTheme);
|
||||
//}
|
||||
#else
|
||||
SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
|
||||
SetTextColor(hdc, GetSysColor(COLOR_BTNTEXT));
|
||||
#endif
|
||||
|
||||
WCHAR text[256] = { L'\0' };
|
||||
HWND const hWndItem = pDIS->hwndItem;
|
||||
int const len = (int)SendMessage(hWndItem, WM_GETTEXT, ARRAYSIZE(text), (LPARAM)text);
|
||||
|
||||
RECT rc = pDIS->rcItem;
|
||||
ExtTextOut(hdc, rc.left + 2, rc.top + 2, ETO_OPAQUE | ETO_NUMERICSLOCAL, &rc, text, len, NULL);
|
||||
|
||||
//~EndPaint(hWndItem, &ps);
|
||||
return TRUE;
|
||||
}
|
||||
// ============================================================================
|
||||
#endif
|
||||
|
||||
#if FALSE
|
||||
//=============================================================================
|
||||
//
|
||||
// OwnerDrawItem() - Handles WM_DRAWITEM
|
||||
// https://docs.microsoft.com/en-us/windows/win32/controls/status-bars#owner-drawn-status-bars
|
||||
//
|
||||
extern "C" LRESULT OwnerDrawTextItem(HWND hwnd, WPARAM wParam, LPARAM lParam) {
|
||||
(void)(hwnd);
|
||||
(void)(wParam); // sender control
|
||||
|
||||
const DRAWITEMSTRUCT *const pDIS = (const DRAWITEMSTRUCT *const)lParam;
|
||||
|
||||
//UINT const ctlId = pDIS->CtlID;
|
||||
//LPCWSTR const data = (LPCWSTR)(pDIS->itemData);
|
||||
|
||||
//~PAINTSTRUCT ps;
|
||||
//~BeginPaint(hWndItem, &ps); ~ not needed on WM_DRAWITEM
|
||||
|
||||
HWND const hwndButton = pDIS->hwndItem;
|
||||
HTHEME const hTheme = OpenThemeData(hwndButton, L"Button");
|
||||
if (hTheme) {
|
||||
RECT rc;
|
||||
GetWindowRect(hwndButton, &rc);
|
||||
|
||||
HDC const hdc = pDIS->hDC;
|
||||
int const partId = BS_AUTORADIOBUTTON; // (int)pDIS->partID;
|
||||
int const stateId = BST_UNCHECKED; // (int)pDIS->itemState;
|
||||
HRESULT hr = DrawThemeBackground(hTheme, hdc, partId, stateId, &rc, 0);
|
||||
RECT rcContent = { 0 };
|
||||
if (SUCCEEDED(hr)) {
|
||||
hr = GetThemeBackgroundContentRect(hTheme, hdc, partId, stateId, &rc, &rcContent);
|
||||
}
|
||||
if (SUCCEEDED(hr)) {
|
||||
WCHAR szButtonText[255];
|
||||
int const len = GetWindowText(hwndButton, szButtonText, ARRAYSIZE(szButtonText));
|
||||
hr = DrawThemeText(hTheme, hdc, partId, stateId, szButtonText, len, DT_LEFT | DT_VCENTER | DT_SINGLELINE, 0, &rcContent);
|
||||
}
|
||||
CloseThemeData(hTheme);
|
||||
//~EndPaint(hWndItem, &ps);
|
||||
return SUCCEEDED(hr);
|
||||
}
|
||||
//~EndPaint(hWndItem, &ps);
|
||||
return FALSE;
|
||||
}
|
||||
// ============================================================================
|
||||
#endif
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ extern "C" {
|
||||
extern COLORREF g_rgbDarkTextColor;
|
||||
extern HBRUSH g_hbrWndDarkBkgBrush;
|
||||
|
||||
void InitDarkMode();
|
||||
void InitDarkMode(bool bEnableDarkMode);
|
||||
void InitListView(HWND hListView);
|
||||
void InitTreeView(HWND hTreeView);
|
||||
void ReleaseDarkMode();
|
||||
|
||||
@ -4800,18 +4800,18 @@ static WCHAR szCachedFile[MAX_PATH] = { L'\0' };
|
||||
static WCHAR szCachedDisplayName[MAX_PATH] = { L'\0' };
|
||||
static WCHAR szAdditionalTitleInfo[MAX_PATH] = { L'\0' };
|
||||
|
||||
bool SetWindowTitle(HWND hwnd, UINT uIDAppName, bool bIsElevated, UINT uIDUntitled,
|
||||
void SetWindowTitle(HWND hwnd, UINT uIDAppName, bool bIsElevated, UINT uIDUntitled,
|
||||
LPCWSTR lpszFile, int iFormat, bool bModified,
|
||||
UINT uIDReadOnly, bool bReadOnly, LPCWSTR lpszExcerpt)
|
||||
{
|
||||
if (bFreezeAppTitle) {
|
||||
return FALSE;
|
||||
return;
|
||||
}
|
||||
WCHAR szAppName[SMALL_BUFFER] = { L'\0' };
|
||||
WCHAR szUntitled[SMALL_BUFFER] = { L'\0' };
|
||||
if (!GetLngString(uIDAppName, szAppName, COUNTOF(szAppName)) ||
|
||||
!GetLngString(uIDUntitled, szUntitled, COUNTOF(szUntitled))) {
|
||||
return FALSE;
|
||||
return;
|
||||
}
|
||||
if (bIsElevated) {
|
||||
WCHAR szElevatedAppName[SMALL_BUFFER] = { L'\0' };
|
||||
@ -4875,8 +4875,7 @@ bool SetWindowTitle(HWND hwnd, UINT uIDAppName, bool bIsElevated, UINT uIDUntitl
|
||||
StringCchCat(szTitle, COUNTOF(szTitle), szAdditionalTitleInfo);
|
||||
}
|
||||
|
||||
return SetWindowText(hwnd, szTitle);
|
||||
|
||||
SetWindowText(hwnd, szTitle);
|
||||
}
|
||||
|
||||
void SetAdditionalTitleInfo(LPCWSTR lpszAddTitleInfo)
|
||||
|
||||
@ -66,7 +66,7 @@ INT_PTR InfoBoxLng(UINT uType, LPCWSTR lpstrSetting, UINT uidMsg, ...);
|
||||
DWORD MsgBoxLastError(LPCWSTR lpszMessage, DWORD dwErrID);
|
||||
DWORD DbgMsgBoxLastError(LPCWSTR lpszMessage, DWORD dwErrID);
|
||||
|
||||
bool SetWindowTitle(HWND hwnd, UINT uIDAppName, bool bIsElevated, UINT uIDUntitled,
|
||||
void SetWindowTitle(HWND hwnd, UINT uIDAppName, bool bIsElevated, UINT uIDUntitled,
|
||||
LPCWSTR lpszFile, int iFormat, bool bModified,
|
||||
UINT uIDReadOnly, bool bReadOnly, LPCWSTR lpszExcerpt);
|
||||
void SetAdditionalTitleInfo(LPCWSTR lpszAddTitleInfo);
|
||||
|
||||
@ -409,7 +409,7 @@ void ObserveNotifyChangeEvent()
|
||||
}
|
||||
if (CheckNotifyChangeEvent()) {
|
||||
EditUpdateVisibleIndicators();
|
||||
UpdateToolbar();
|
||||
//@@@ §§§ UpdateToolbar();
|
||||
UpdateStatusbar(false);
|
||||
}
|
||||
}
|
||||
@ -575,12 +575,16 @@ static void SetSaveNeeded()
|
||||
}
|
||||
}
|
||||
s_DocNeedSaving = true;
|
||||
UpdateToolbar();
|
||||
UpdateTitleBar();
|
||||
}
|
||||
|
||||
void SetSavePoint()
|
||||
{
|
||||
s_DocNeedSaving = false;
|
||||
if (SciCall_GetModify()) { SciCall_SetSavePoint(); }
|
||||
UpdateToolbar();
|
||||
UpdateTitleBar();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
@ -597,10 +601,6 @@ static void _InitGlobals()
|
||||
|
||||
ZeroMemory(&(Globals.fvCurFile), sizeof(FILEVARS));
|
||||
|
||||
#ifdef D_NP3_WIN10_DARK_MODE
|
||||
InitDarkMode();
|
||||
#endif
|
||||
|
||||
Globals.WindowsBuildNumber = GetWindowsBuildNumber(NULL, NULL);
|
||||
|
||||
Globals.hDlgIcon256 = NULL;
|
||||
@ -858,6 +858,8 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
|
||||
}
|
||||
LoadSettings();
|
||||
|
||||
InitDarkMode(true); // try
|
||||
|
||||
// set AppUserModelID
|
||||
PrivateSetCurrentProcessExplicitAppUserModelID(Settings2.AppUserModelID);
|
||||
|
||||
@ -989,6 +991,8 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
|
||||
return 1;
|
||||
}
|
||||
|
||||
InitDarkMode(IsDarkModeSupported() && Settings.WinThemeDarkMode); // settings
|
||||
|
||||
HWND const hwnd = InitInstance(Globals.hInstance, lpCmdLine, nShowCmd);
|
||||
if (!hwnd) {
|
||||
_CleanUpResources(hwnd, true);
|
||||
@ -1676,7 +1680,6 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
#ifdef D_NP3_WIN10_DARK_MODE
|
||||
case WM_SETTINGCHANGE: {
|
||||
if (IsColorSchemeChangeMessage(lParam)) {
|
||||
CheckDarkModeEnabled();
|
||||
RefreshTitleBarThemeColor(hwnd);
|
||||
SendMessage(Globals.hwndEdit, WM_THEMECHANGED, 0, 0);
|
||||
}
|
||||
@ -2746,7 +2749,6 @@ LRESULT MsgThemeChanged(HWND hwnd, WPARAM wParam ,LPARAM lParam)
|
||||
RECT rc, rc2;
|
||||
|
||||
// reinitialize edit frame
|
||||
|
||||
if (IsAppThemed()) {
|
||||
s_bIsAppThemed = true;
|
||||
|
||||
@ -2797,11 +2799,16 @@ LRESULT MsgThemeChanged(HWND hwnd, WPARAM wParam ,LPARAM lParam)
|
||||
|
||||
EditUpdateVisibleIndicators();
|
||||
|
||||
#ifdef D_NP3_WIN10_DARK_MODE
|
||||
AllowDarkModeForWindow(hwnd, UseDarkMode());
|
||||
RefreshTitleBarThemeColor(hwnd);
|
||||
#endif
|
||||
|
||||
UpdateUI();
|
||||
UpdateToolbar();
|
||||
UpdateStatusbar(true);
|
||||
UpdateMarginWidth();
|
||||
EditUpdateVisibleIndicators();
|
||||
UpdateTitleBar();
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@ -3700,6 +3707,9 @@ LRESULT MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
CheckMenuRadioItem(hmenu, IDM_VIEW_HILITCURLN_NONE, IDM_VIEW_HILITCURLN_FRAME, i, MF_BYCOMMAND);
|
||||
CheckCmdPos(GetSubMenu(GetMenu(Globals.hwndMain), 2), 12, (i != IDM_VIEW_HILITCURLN_NONE));
|
||||
|
||||
EnableCmd(hmenu, IDM_VIEW_WIN_DARK_MODE, IsDarkModeSupported());
|
||||
CheckCmd(hmenu, IDM_VIEW_WIN_DARK_MODE, Settings.WinThemeDarkMode);
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
int const mnuMain = 2;
|
||||
@ -5846,6 +5856,16 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
break;
|
||||
|
||||
case IDM_VIEW_WIN_DARK_MODE:
|
||||
Settings.WinThemeDarkMode = !Settings.WinThemeDarkMode;
|
||||
InitDarkMode(Settings.WinThemeDarkMode);
|
||||
SciCall_SetHScrollbar(false);
|
||||
SciCall_SetHScrollbar(true);
|
||||
SciCall_SetVScrollbar(false);
|
||||
SciCall_SetVScrollbar(true);
|
||||
PostMessage(hwnd, WM_THEMECHANGED, 0, 0);
|
||||
break;
|
||||
|
||||
case IDM_VIEW_MUTE_MESSAGEBEEP:
|
||||
Settings.MuteMessageBeep = !Settings.MuteMessageBeep;
|
||||
break;
|
||||
@ -5864,11 +5884,13 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
case IDM_VIEW_SHOWFULLPATH:
|
||||
Settings.PathNameFormat = iLoWParam - IDM_VIEW_SHOWFILENAMEONLY;
|
||||
StringCchCopy(s_wchTitleExcerpt,COUNTOF(s_wchTitleExcerpt),L"");
|
||||
UpdateTitleBar();
|
||||
break;
|
||||
|
||||
|
||||
case IDM_VIEW_SHOWEXCERPT:
|
||||
EditGetExcerpt(Globals.hwndEdit,s_wchTitleExcerpt,COUNTOF(s_wchTitleExcerpt));
|
||||
UpdateTitleBar();
|
||||
break;
|
||||
|
||||
|
||||
@ -6407,6 +6429,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
case CMD_TOGGLETITLE:
|
||||
EditGetExcerpt(Globals.hwndEdit,s_wchTitleExcerpt,COUNTOF(s_wchTitleExcerpt));
|
||||
UpdateTitleBar();
|
||||
break;
|
||||
|
||||
|
||||
@ -7583,16 +7606,18 @@ static LRESULT _MsgNotifyFromEdit(HWND hwnd, const LPNMHDR pnmh, const SCNotific
|
||||
MarkAllOccurrences(Settings2.UpdateDelayMarkAllOccurrences, true);
|
||||
}
|
||||
else {
|
||||
EditClearAllOccurrenceMarkers(Globals.hwndEdit);
|
||||
if (Globals.iMarkOccurrencesCount > 0) {
|
||||
EditClearAllOccurrenceMarkers(Globals.hwndEdit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//~else if (iUpd & SC_UPDATE_CONTENT) {
|
||||
//~if (iUpd & SC_UPDATE_CONTENT) {
|
||||
//~ ignoring SC_UPDATE_CONTENT cause Style and Marker are out of scope here
|
||||
//~ using WM_COMMAND -> SCEN_CHANGE instead!
|
||||
//~~~MarkAllOccurrences(Settings2.UpdateDelayMarkAllCoccurrences, false);
|
||||
//~~~EditUpdateVisibleIndicators(); // will lead to recursion
|
||||
//}
|
||||
//~}
|
||||
HandlePosChange();
|
||||
UpdateToolbar();
|
||||
UpdateMarginWidth();
|
||||
@ -8566,8 +8591,6 @@ void UpdateToolbar()
|
||||
static void _UpdateToolbarDelayed()
|
||||
{
|
||||
bool const bDocModified = GetDocModified();
|
||||
SetWindowTitle(Globals.hwndMain, s_uidsAppTitle, s_bIsProcessElevated, IDS_MUI_UNTITLED, Globals.CurrentFile,
|
||||
Settings.PathNameFormat, bDocModified, IDS_MUI_READONLY, s_bFileReadOnly, s_wchTitleExcerpt);
|
||||
|
||||
if (!Settings.ShowToolbar) { return; }
|
||||
|
||||
@ -9385,6 +9408,17 @@ void UpdateUI()
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// UpdateTitleBar()
|
||||
//
|
||||
void UpdateTitleBar() {
|
||||
SetWindowTitle(Globals.hwndMain, s_uidsAppTitle, s_bIsProcessElevated, IDS_MUI_UNTITLED, Globals.CurrentFile,
|
||||
Settings.PathNameFormat, GetDocModified(), IDS_MUI_READONLY, s_bFileReadOnly, s_wchTitleExcerpt);
|
||||
PostMessage(Globals.hwndMain, WM_NCACTIVATE, FALSE, -1);
|
||||
PostMessage(Globals.hwndMain, WM_NCACTIVATE, TRUE, 0);
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
|
||||
|
||||
@ -131,6 +131,7 @@ void UpdateStatusbar(bool);
|
||||
void UpdateMarginWidth();
|
||||
void UpdateSaveSettingsCmds();
|
||||
void UpdateMouseDWellTime();
|
||||
void UpdateTitleBar();
|
||||
|
||||
void UndoRedoRecordingStart();
|
||||
void UndoRedoRecordingStop();
|
||||
|
||||
@ -383,6 +383,10 @@ DeclareSciCallV1(SetFirstVisibleLine, SETFIRSTVISIBLELINE, DocLn, line)
|
||||
DeclareSciCallR1(VisibleFromDocLine, VISIBLEFROMDOCLINE, DocLn, DocLn, line)
|
||||
DeclareSciCallR1(DocLineFromVisible, DOCLINEFROMVISIBLE, DocLn, DocLn, line)
|
||||
|
||||
DeclareSciCallV1(SetHScrollbar, SETHSCROLLBAR, bool, visible)
|
||||
DeclareSciCallV1(SetVScrollbar, SETVSCROLLBAR, bool, visible)
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Style definition
|
||||
@ -407,7 +411,8 @@ DeclareSciCallV1(SetHotspotSigleLine, SETHOTSPOTSINGLELINE, bool, singleline)
|
||||
DeclareSciCallV1(SetViewWS, SETVIEWWS, int, wspc)
|
||||
DeclareSciCallV1(SetViewEOL, SETVIEWEOL, bool, eols)
|
||||
|
||||
//=============================================================================
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Indentation Guides and Wraping
|
||||
//
|
||||
@ -487,7 +492,7 @@ DeclareSciCallV2(MarkerSetBackSelected, MARKERSETBACKSELECTED, int, markerNumber
|
||||
DeclareSciCallR2(MarkerNext, MARKERNEXT, DocLn, DocLn, start, int, markerMask)
|
||||
DeclareSciCallR2(MarkerPrevious, MARKERPREVIOUS, DocLn, DocLn, start, int, markerMask)
|
||||
|
||||
//=============================================================================
|
||||
//=============================================================================
|
||||
//
|
||||
// Line State
|
||||
//
|
||||
|
||||
@ -498,7 +498,7 @@ typedef struct _settings_t
|
||||
bool EditLayoutRTL;
|
||||
bool DialogsLayoutRTL;
|
||||
int FocusViewMarkerMode;
|
||||
int WinThemeDarkMode; // 0=disabled, 1=enabled, 2=auto
|
||||
bool WinThemeDarkMode;
|
||||
|
||||
RECT PrintMargin;
|
||||
EDITFINDREPLACE EFR_Data;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user