From 7fe5558a09868ea45525777e23e2eac17c24b30f Mon Sep 17 00:00:00 2001 From: "METANEOCORTEX\\Kotti" Date: Mon, 7 Nov 2022 01:39:37 +0100 Subject: [PATCH] +chg: Workaround to fix DPI scaling issues related to VS2022 compiler toolset +fix: don't store contrast adapted dark mode foreground color themes --- Version.ps1 | 41 ++++----- Versions/Notepad3.exe.manifest.tpl | 17 ++-- res/Notepad3.exe.conf.manifest | 11 +++ res/Notepad3.exe.manifest | 84 +++++++++--------- res/Notepad3.exe.manifest.conf | 10 --- src/Dialogs.c | 47 +++++----- src/Edit.c | 38 ++++----- src/Helpers.c | 8 +- src/Helpers.h | 2 +- src/Notepad3.c | 11 ++- src/Notepad3.vcxproj | 36 ++++---- src/Print.cpp | 4 +- src/Styles.c | 132 +++++++++++++++-------------- src/Styles.h | 2 +- src/crypto/crypto.c | 4 +- 15 files changed, 225 insertions(+), 222 deletions(-) create mode 100644 res/Notepad3.exe.conf.manifest delete mode 100644 res/Notepad3.exe.manifest.conf diff --git a/Version.ps1 b/Version.ps1 index 672e13808..53ad9b517 100644 --- a/Version.ps1 +++ b/Version.ps1 @@ -45,14 +45,14 @@ try if ($AppVeyorEnv) { if ($LastBuildDay -ne "$Revis") { - $Revis | Set-Content "Versions\day.txt" + $Revis | Set-Content -Path "Versions\day.txt" $Build = 1 # reset (AppVeyor) } $CommitID = ([string]($env:appveyor_repo_commit)).substring(0,8) } else { if ($LastBuildDay -ne "$Revis") { - $Revis | Set-Content "Versions\day.txt" + $Revis | Set-Content -Path "Versions\day.txt" $Build = 0 # reset (local build) } # locally: increase build number and persit it @@ -73,7 +73,7 @@ try } } if (!$CommitID) { $CommitID = "---" } - $Build | Set-Content "Versions\build.txt" + $Build | Set-Content -Path "Versions\build.txt" $CompleteVer = "$Major.$Minor.$Revis.$Build" DebugOutput("Notepad3 version number: 'v$CompleteVer $VerPatch'") @@ -101,24 +101,25 @@ try #~if ($VerPatch) { $VerPatch = " $VerPatch" } # ensure space in front of string Copy-Item -LiteralPath "Versions\VersionEx.h.tpl" -Destination "src\VersionEx.h" -Force - (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$APPNAME\$', "$AppName" } | Set-Content "src\VersionEx.h" - (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$MAJOR\$', "$Major" } | Set-Content "src\VersionEx.h" - (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$MINOR\$', "$Minor" } | Set-Content "src\VersionEx.h" - (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$MAINT\$', "$Revis" } | Set-Content "src\VersionEx.h" - (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$BUILD\$', "$Build" } | Set-Content "src\VersionEx.h" - (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$SCIVER\$', "$SciVer" } | Set-Content "src\VersionEx.h" - (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$LXIVER\$', "$LxiVer" } | Set-Content "src\VersionEx.h" - (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$ONIGURUMAVER\$', "$OnigVer" } | Set-Content "src\VersionEx.h" - (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$UCHARDETVER\$', "$UChardetVer" } | Set-Content "src\VersionEx.h" - (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$TINYEXPRVER\$', "$TinyExprVer" } | Set-Content "src\VersionEx.h" - (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$UTHASHVER\$', "$UtHashVer" } | Set-Content "src\VersionEx.h" - (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$VERPATCH\$', "$VerPatch" } | Set-Content "src\VersionEx.h" - (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$COMMITID\$', "$CommitID" } | Set-Content "src\VersionEx.h" + (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$APPNAME\$', "$AppName" } | Set-Content -Path "src\VersionEx.h" + (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$MAJOR\$', "$Major" } | Set-Content -Path "src\VersionEx.h" + (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$MINOR\$', "$Minor" } | Set-Content -Path "src\VersionEx.h" + (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$MAINT\$', "$Revis" } | Set-Content -Path "src\VersionEx.h" + (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$BUILD\$', "$Build" } | Set-Content -Path "src\VersionEx.h" + (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$SCIVER\$', "$SciVer" } | Set-Content -Path "src\VersionEx.h" + (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$LXIVER\$', "$LxiVer" } | Set-Content -Path "src\VersionEx.h" + (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$ONIGURUMAVER\$', "$OnigVer" } | Set-Content -Path "src\VersionEx.h" + (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$UCHARDETVER\$', "$UChardetVer" } | Set-Content -Path "src\VersionEx.h" + (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$TINYEXPRVER\$', "$TinyExprVer" } | Set-Content -Path "src\VersionEx.h" + (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$UTHASHVER\$', "$UtHashVer" } | Set-Content -Path "src\VersionEx.h" + (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$VERPATCH\$', "$VerPatch" } | Set-Content -Path "src\VersionEx.h" + (Get-Content "src\VersionEx.h") | ForEach-Object { $_ -replace '\$COMMITID\$', "$CommitID" } | Set-Content -Path "src\VersionEx.h" - Copy-Item -LiteralPath "Versions\Notepad3.exe.manifest.tpl" -Destination "res\Notepad3.exe.manifest.conf" -Force - (Get-Content "res\Notepad3.exe.manifest.conf") | ForEach-Object { $_ -replace '\$APPNAME\$', "$AppName" } | Set-Content "res\Notepad3.exe.manifest.conf" - (Get-Content "res\Notepad3.exe.manifest.conf") | ForEach-Object { $_ -replace '\$VERPATCH\$', "$VerPatch" } | Set-Content "res\Notepad3.exe.manifest.conf" - (Get-Content "res\Notepad3.exe.manifest.conf") | ForEach-Object { $_ -replace '\$VERSION\$', "$CompleteVer" } | Set-Content "res\Notepad3.exe.manifest.conf" + $confManifest = "res\Notepad3.exe.conf.manifest" + Copy-Item -LiteralPath "Versions\Notepad3.exe.manifest.tpl" -Destination $confManifest -Force + (Get-Content $confManifest) | ForEach-Object { $_ -replace '\$APPNAME\$', "$AppName" } | Set-Content -Path $confManifest + (Get-Content $confManifest) | ForEach-Object { $_ -replace '\$VERPATCH\$', "$VerPatch" } | Set-Content -Path $confManifest + (Get-Content $confManifest) | ForEach-Object { $_ -replace '\$VERSION\$', "$CompleteVer" } | Set-Content -Path $confManifest } catch { diff --git a/Versions/Notepad3.exe.manifest.tpl b/Versions/Notepad3.exe.manifest.tpl index 13244ad74..2d97ee6e6 100644 --- a/Versions/Notepad3.exe.manifest.tpl +++ b/Versions/Notepad3.exe.manifest.tpl @@ -1,10 +1,11 @@ - - - $APPNAME$ $VERPATCH$ + + + + $APPNAME$ $VERPATCH$ diff --git a/res/Notepad3.exe.conf.manifest b/res/Notepad3.exe.conf.manifest new file mode 100644 index 000000000..f0e40cb42 --- /dev/null +++ b/res/Notepad3.exe.conf.manifest @@ -0,0 +1,11 @@ + + + + + Notepad3 beta + diff --git a/res/Notepad3.exe.manifest b/res/Notepad3.exe.manifest index 63766f3b7..9a38eda3f 100644 --- a/res/Notepad3.exe.manifest +++ b/res/Notepad3.exe.manifest @@ -1,50 +1,42 @@ + - Notepad3 - - - - - - - - - - - - - - - - - - - - - - - - - true/PM - - - PerMonitorV2,PerMonitor - - - true - + + + + + + + + + + + + + + + + + true/PM + + + + PerMonitorV2, PerMonitor + + + true + - true - - + false + + + + + + + + + + + diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf deleted file mode 100644 index 66ed39c40..000000000 --- a/res/Notepad3.exe.manifest.conf +++ /dev/null @@ -1,10 +0,0 @@ - - - - Notepad3 beta - diff --git a/src/Dialogs.c b/src/Dialogs.c index 25a7db4c4..36955b3c3 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -306,7 +306,7 @@ static INT_PTR CALLBACK _InfoBoxLngDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, if (hIconBmp) { SetBitmapControl(hwnd, IDC_INFOBOXICON, hIconBmp); } - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); } return TRUE; @@ -767,7 +767,7 @@ static INT_PTR CALLBACK CmdLineHelpProc(HWND hwnd, UINT umsg, WPARAM wParam, LPA return TRUE; case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); return TRUE; #ifdef D_NP3_WIN10_DARK_MODE @@ -1076,7 +1076,7 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam SendDlgItemMessageW(hwnd, IDC_VERSION, WM_SETFONT, (WPARAM)hVersionFont, true); } - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); } break; @@ -1318,7 +1318,7 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM l case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); return TRUE; @@ -1571,7 +1571,7 @@ static INT_PTR CALLBACK OpenWithDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); return TRUE; @@ -1827,7 +1827,7 @@ static INT_PTR CALLBACK FavoritesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARA case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); return TRUE; @@ -2045,7 +2045,7 @@ static INT_PTR CALLBACK AddToFavDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPA case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); break; @@ -2349,7 +2349,7 @@ static INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPAR return TRUE; case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, (RECT *)lParam, 0); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); return TRUE; case WM_GETMINMAXINFO: @@ -2649,7 +2649,7 @@ static INT_PTR CALLBACK ChangeNotifyDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, return TRUE; case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); return TRUE; #ifdef D_NP3_WIN10_DARK_MODE @@ -2811,7 +2811,7 @@ static INT_PTR CALLBACK ColumnWrapDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, L case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); return TRUE; @@ -2958,7 +2958,7 @@ static INT_PTR CALLBACK WordWrapSettingsDlgProc(HWND hwnd, UINT umsg, WPARAM wPa case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); return TRUE; @@ -3102,7 +3102,7 @@ static INT_PTR CALLBACK LongLineSettingsDlgProc(HWND hwnd, UINT umsg, WPARAM wPa case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); return TRUE; @@ -3260,7 +3260,7 @@ static INT_PTR CALLBACK TabSettingsDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPA case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); return TRUE; @@ -3435,7 +3435,7 @@ static INT_PTR CALLBACK SelectDefEncodingDlgProc(HWND hwnd, UINT umsg, WPARAM wP case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); return TRUE; @@ -3632,7 +3632,7 @@ static INT_PTR CALLBACK SelectEncodingDlgProc(HWND hwnd,UINT umsg,WPARAM wParam, case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); return TRUE; @@ -3862,7 +3862,7 @@ static INT_PTR CALLBACK SelectDefLineEndingDlgProc(HWND hwnd,UINT umsg,WPARAM wP case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); return TRUE; @@ -6255,19 +6255,22 @@ void SetUACIcon(HWND hwnd, const HMENU hMenu, const UINT nItem) // // UpdateWindowLayoutForDPI() // -void UpdateWindowLayoutForDPI(HWND hwnd, const RECT *pNewRect, const UINT adpi) { +#define USE_RECT_FOR_WIN_POS true + +void UpdateWindowLayoutForDPI(HWND hwnd, const RECT *pNewRect, const UINT dpi) +{ UINT const uWndFlags = SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED; //~ SWP_NOMOVE | SWP_NOSIZE | SWP_NOREPOSITION - if (pNewRect) { + if (pNewRect && (USE_RECT_FOR_WIN_POS || (dpi == 0))) { SetWindowPos(hwnd, NULL, pNewRect->left, pNewRect->top, (pNewRect->right - pNewRect->left), (pNewRect->bottom - pNewRect->top), uWndFlags); } else { RECT rc = { 0 }; GetWindowRect(hwnd, &rc); //~MapWindowPoints(NULL, hWnd, (LPPOINT)&rc, 2); - UINT const dpi = adpi ? adpi : Scintilla_GetWindowDPI(hwnd); - Scintilla_AdjustWindowRectForDpi((LPWRECT)&rc, uWndFlags, 0, dpi); + UINT const _dpi = (dpi < (USER_DEFAULT_SCREEN_DPI >> 2)) ? Scintilla_GetWindowDPI(hwnd) : dpi; + Scintilla_AdjustWindowRectForDpi((LPWRECT)&rc, uWndFlags, 0, _dpi); SetWindowPos(hwnd, NULL, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), uWndFlags); } RedrawWindow(hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_ERASE | RDW_INTERNALPAINT | RDW_ALLCHILDREN | RDW_UPDATENOW); @@ -6425,7 +6428,7 @@ INT_PTR CALLBACK FontDialogHookProc( case WM_DPICHANGED: dpi = LOWORD(wParam); //dpi.y = HIWORD(wParam); - UpdateWindowLayoutForDPI(hdlg, (RECT *)lParam, 0); + UpdateWindowLayoutForDPI(hdlg, (RECT*)lParam, LOWORD(wParam)); int const ctl[] = { cmb1, cmb2, cmb3, cmb4, cmb5 }; for (int i = 0; i < COUNTOF(ctl); ++i) { HFONT const hFont = (HFONT)SendMessage(GetDlgItem(hdlg, ctl[i]), WM_GETFONT, 0, 0); @@ -6527,7 +6530,7 @@ INT_PTR CALLBACK ColorDialogHookProc( case WM_DPICHANGED: dpi = LOWORD(wParam); //dpi.y = HIWORD(wParam); - UpdateWindowLayoutForDPI(hdlg, (RECT *)lParam, 0); + UpdateWindowLayoutForDPI(hdlg, (RECT*)lParam, LOWORD(wParam)); int const ctl[] = { COLOR_ADD, COLOR_MIX, IDOK, IDCANCEL }; for (int i = 0; i < COUNTOF(ctl); ++i) { HFONT const hFont = (HFONT)SendMessage(GetDlgItem(hdlg, ctl[i]), WM_GETFONT, 0, 0); diff --git a/src/Edit.c b/src/Edit.c index 2d4fdaeb4..6a2bdc4c7 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -6408,11 +6408,9 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar return FALSE; - case WM_DPICHANGED: { - UINT const dpi = LOWORD(wParam); - UpdateWindowLayoutForDPI(hwnd, (RECT *)lParam, dpi); - } - return TRUE; // further processing + case WM_DPICHANGED: + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); + return TRUE; // further processing #ifdef D_NP3_WIN10_DARK_MODE @@ -8346,11 +8344,9 @@ static INT_PTR CALLBACK EditLinenumDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPA return true; - case WM_DPICHANGED: { - UINT const dpi = LOWORD(wParam); - UpdateWindowLayoutForDPI(hwnd, (RECT *)lParam, dpi); - } - return true; + case WM_DPICHANGED: + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); + return TRUE; #ifdef D_NP3_WIN10_DARK_MODE @@ -8539,9 +8535,7 @@ static INT_PTR CALLBACK EditModifyLinesDlgProc(HWND hwnd, UINT umsg, WPARAM wPar } hFontHover = CreateFontIndirectW(&lf); } - //~UINT const dpi = LOWORD(wParam); - //~UpdateWindowLayoutForDPI(hwnd, NULL, dpi); - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); } return TRUE; @@ -8751,8 +8745,8 @@ static INT_PTR CALLBACK EditAlignDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARA return true; case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0); - return true; + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); + return TRUE; #ifdef D_NP3_WIN10_DARK_MODE @@ -8867,7 +8861,7 @@ static INT_PTR CALLBACK EditEncloseSelectionDlgProc(HWND hwnd, UINT umsg, WPARAM return TRUE; case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); return TRUE; #ifdef D_NP3_WIN10_DARK_MODE @@ -8986,11 +8980,11 @@ static INT_PTR CALLBACK EditInsertTagDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,L PostMessageW(GetDlgItem(hwnd, 100), EM_SETSEL, 1, (LPARAM)(StringCchLen(pData->pwsz1, 0) - 1)); CenterDlgInParent(hwnd, NULL); } - return false; + return FALSE; case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0); - return true; + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); + return TRUE; #ifdef D_NP3_WIN10_DARK_MODE @@ -9209,11 +9203,11 @@ static INT_PTR CALLBACK EditSortDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM } CenterDlgInParent(hwnd, NULL); } - return true; + return TRUE; case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0); - return true; + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); + return TRUE; #ifdef D_NP3_WIN10_DARK_MODE diff --git a/src/Helpers.c b/src/Helpers.c index c2e00d460..d6409cc69 100644 --- a/src/Helpers.c +++ b/src/Helpers.c @@ -46,14 +46,14 @@ #if (defined(_DEBUG) || defined(DEBUG)) && !defined(NDEBUG) -void DbgLog(const char *fmt, ...) +void DbgLog(const wchar_t *fmt, ...) { - char buf[1024] = ""; + static wchar_t buf[2048] = { 0 }; va_list va; va_start(va, fmt); - wvsprintfA(buf, fmt, va); + wvnsprintfW(buf, COUNTOF(buf), fmt, va); va_end(va); - OutputDebugStringA(buf); + OutputDebugStringW(buf); } #endif diff --git a/src/Helpers.h b/src/Helpers.h index 72d73c7c3..383ec1df7 100644 --- a/src/Helpers.h +++ b/src/Helpers.h @@ -122,7 +122,7 @@ inline size_t SizeOfMem(LPCVOID lpMem) // ============================================================================ #if (defined(_DEBUG) || defined(DEBUG)) && !defined(NDEBUG) -void DbgLog(const char *fmt, ...); +void DbgLog(const wchar_t *fmt, ...); #else #define DbgLog(fmt, ...) NOOP #endif diff --git a/src/Notepad3.c b/src/Notepad3.c index 34dd0f0a1..a44002d5d 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -1128,8 +1128,8 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, Style_ImportTheme(-1); // init (!) Style_ImportTheme(Globals.uCurrentThemeIndex); - //SetProcessDPIAware(); -> .manifest - //SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE); + //SetProcessDPIAware(); // ->.manifest + //SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); //~Scintilla_LoadDpiForWindow(); done in Sci::Platform_Initialize(); // ---------------------------------------------------- @@ -1265,6 +1265,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, MSG msg; while (GetMessage(&msg,NULL,0,0)) { + if (IsWindow(Globals.hwndDlgFindReplace) && ((msg.hwnd == Globals.hwndDlgFindReplace) || IsChild(Globals.hwndDlgFindReplace, msg.hwnd))) { const int iTr = TranslateAccelerator(Globals.hwndDlgFindReplace, hAccFindReplace, &msg); if (iTr || IsDialogMessage(Globals.hwndDlgFindReplace, &msg)) { @@ -3195,12 +3196,14 @@ LRESULT MsgEndSession(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) // LRESULT MsgDPIChanged(HWND hwnd, WPARAM wParam, LPARAM lParam) { - //UINT const dpi = LOWORD(wParam); + UINT const dpi = LOWORD(wParam); + DbgLog(L"MsgDPIChanged() -> %u\n", dpi); + const RECT* const rc = (RECT*)lParam; DocPos const pos = SciCall_GetCurrentPos(); - UpdateWindowLayoutForDPI(hwnd, rc, 0); + UpdateWindowLayoutForDPI(hwnd, rc, dpi); SendMessage(Globals.hwndEdit, WM_DPICHANGED, wParam, lParam); diff --git a/src/Notepad3.vcxproj b/src/Notepad3.vcxproj index 36e9862a8..ebc11e754 100644 --- a/src/Notepad3.vcxproj +++ b/src/Notepad3.vcxproj @@ -38,7 +38,7 @@ Application v141 v142 - v143 + v142 true true false @@ -49,7 +49,7 @@ Application v141 v142 - v143 + v142 false true false @@ -60,7 +60,7 @@ Application v141 v142 - v143 + v142 false true false @@ -70,7 +70,7 @@ Application v141 v142 - v143 + v142 true true false @@ -81,7 +81,7 @@ Application v141 v142 - v143 + v142 false true false @@ -91,7 +91,7 @@ Application v141 v142 - v143 + v142 false true false @@ -123,36 +123,42 @@ ..\Bin\$(Configuration)_$(PlatformShortName)_$(PlatformToolset)\obj\$(ProjectName)\ false ..\Bin\$(Configuration)_$(PlatformShortName)_$(PlatformToolset)\ + true true ..\Bin\$(Configuration)_$(PlatformShortName)_$(PlatformToolset)\obj\$(ProjectName)\ false ..\Bin\$(Configuration)_$(PlatformShortName)_$(PlatformToolset)\ + true true ..\Bin\$(Configuration)_$(PlatformShortName)_$(PlatformToolset)\obj\$(ProjectName)\ false ..\Bin\$(Configuration)_$(PlatformShortName)_$(PlatformToolset)\ + true true ..\Bin\$(Configuration)_$(PlatformShortName)_$(PlatformToolset)\obj\$(ProjectName)\ false ..\Bin\$(Configuration)_$(PlatformShortName)_$(PlatformToolset)\ + true true ..\Bin\$(Configuration)_$(PlatformShortName)_$(PlatformToolset)\obj\$(ProjectName)\ false ..\Bin\$(Configuration)_$(PlatformShortName)_$(PlatformToolset)\ + true true ..\Bin\$(Configuration)_$(PlatformShortName)_$(PlatformToolset)\obj\$(ProjectName)\ false ..\Bin\$(Configuration)_$(PlatformShortName)_$(PlatformToolset)\ + true @@ -213,8 +219,7 @@ - $(IntDir)$(TargetName)$(TargetExt).embed.manifest - $(ProjDir)..\res\$(TargetName)$(TargetExt).manifest.conf + $(ProjDir)..\res\$(TargetName)$(TargetExt).conf.manifest PerMonitorHighDPIAware @@ -288,8 +293,7 @@ - $(IntDir)$(TargetName)$(TargetExt).embed.manifest - $(ProjDir)..\res\$(TargetName)$(TargetExt).manifest.conf + $(ProjDir)..\res\$(TargetName)$(TargetExt).conf.manifest PerMonitorHighDPIAware @@ -373,8 +377,7 @@ - $(IntDir)$(TargetName)$(TargetExt).embed.manifest - $(ProjDir)..\res\$(TargetName)$(TargetExt).manifest.conf + $(ProjDir)..\res\$(TargetName)$(TargetExt).conf.manifest PerMonitorHighDPIAware @@ -452,8 +455,7 @@ - $(IntDir)$(TargetName)$(TargetExt).embed.manifest - $(ProjDir)..\res\$(TargetName)$(TargetExt).manifest.conf + $(ProjDir)..\res\$(TargetName)$(TargetExt).conf.manifest PerMonitorHighDPIAware @@ -536,8 +538,7 @@ - $(IntDir)$(TargetName)$(TargetExt).embed.manifest - $(ProjDir)..\res\$(TargetName)$(TargetExt).manifest.conf + $(ProjDir)..\res\$(TargetName)$(TargetExt).conf.manifest PerMonitorHighDPIAware @@ -614,8 +615,7 @@ - $(IntDir)$(TargetName)$(TargetExt).embed.manifest - $(ProjDir)..\res\$(TargetName)$(TargetExt).manifest.conf + $(ProjDir)..\res\$(TargetName)$(TargetExt).conf.manifest PerMonitorHighDPIAware diff --git a/src/Print.cpp b/src/Print.cpp index e4329ae7d..472246cd0 100644 --- a/src/Print.cpp +++ b/src/Print.cpp @@ -99,7 +99,7 @@ static UINT_PTR CALLBACK _LPPrintHookProc(HWND hwnd, UINT uiMsg, WPARAM wParam, break; case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); break; #ifdef D_NP3_WIN10_DARK_MODE @@ -612,7 +612,7 @@ static UINT_PTR CALLBACK _LPSetupHookProc(HWND hwnd, UINT uiMsg, WPARAM wParam, break; case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hwnd, (RECT *)lParam, 0); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); break; #ifdef D_NP3_WIN10_DARK_MODE diff --git a/src/Styles.c b/src/Styles.c index ddc988982..932386e5f 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -1334,7 +1334,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) pCurrentStandard->Styles[STY_BRACE_OK].szValue); // brace light } else { - if (Style_StrGetColor(pCurrentStandard->Styles[STY_BRACE_OK].szValue, FOREGROUND_LAYER, &dColor, false)) { + if (Style_StrGetColor(pCurrentStandard->Styles[STY_BRACE_OK].szValue, FOREGROUND_LAYER, &dColor, NULL, false)) { SciCall_IndicSetFore(INDIC_NP3_MATCH_BRACE, dColor); } if (Style_StrGetAlpha(pCurrentStandard->Styles[STY_BRACE_OK].szValue, &iValue, true)) { @@ -1363,7 +1363,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) pCurrentStandard->Styles[STY_BRACE_BAD].szValue); // brace bad } else { - if (Style_StrGetColor(pCurrentStandard->Styles[STY_BRACE_BAD].szValue, FOREGROUND_LAYER, &dColor, false)) { + if (Style_StrGetColor(pCurrentStandard->Styles[STY_BRACE_BAD].szValue, FOREGROUND_LAYER, &dColor, NULL, false)) { SciCall_IndicSetFore(INDIC_NP3_BAD_BRACE, dColor); } if (Style_StrGetAlpha(pCurrentStandard->Styles[STY_BRACE_BAD].szValue, &iValue, true)) { @@ -1389,7 +1389,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) } // Occurrences Marker - if (!Style_StrGetColor(pCurrentStandard->Styles[STY_MARK_OCC].szValue, FOREGROUND_LAYER, &dColor, false)) { + if (!Style_StrGetColor(pCurrentStandard->Styles[STY_MARK_OCC].szValue, FOREGROUND_LAYER, &dColor, NULL, false)) { dColor = GetSysColor(COLOR_HIGHLIGHT); WCHAR sty[32] = { L'\0' }; Style_PrintfCchColor(sty, COUNTOF(sty), L"; ", FOREGROUND_LAYER, dColor); @@ -1435,7 +1435,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) SciCall_IndicSetStrokeWidth(INDIC_NP3_UNICODE_POINT, iValue); } - if (Style_StrGetColor(pCurrentStandard->Styles[STY_UNICODE_HOTSPOT].szValue, FOREGROUND_LAYER, &dColor, false)) { + if (Style_StrGetColor(pCurrentStandard->Styles[STY_UNICODE_HOTSPOT].szValue, FOREGROUND_LAYER, &dColor, NULL, false)) { SciCall_IndicSetHoverFore(INDIC_NP3_UNICODE_POINT, dColor); } if (Style_StrGetAlpha(pCurrentStandard->Styles[STY_UNICODE_HOTSPOT].szValue, &iValue, true)) { @@ -1455,7 +1455,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) SciCall_IndicSetHoverStyle(INDIC_NP3_UNICODE_POINT, iValue); // Multi Edit Indicator - if (Style_StrGetColor(pCurrentStandard->Styles[STY_MULTI_EDIT].szValue, FOREGROUND_LAYER, &dColor, false)) { + if (Style_StrGetColor(pCurrentStandard->Styles[STY_MULTI_EDIT].szValue, FOREGROUND_LAYER, &dColor, NULL, false)) { SciCall_IndicSetFore(INDIC_NP3_MULTI_EDIT, dColor); } if (Style_StrGetAlpha(pCurrentStandard->Styles[STY_MULTI_EDIT].szValue, &iValue, true)) { @@ -1486,7 +1486,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) #define _SC_INDIC_IME_UNKNOWN INDIC_IME_MAX COLORREF rgb = RGB(0xFF, 0xA0, 0x00); - Style_StrGetColor(pCurrentStandard->Styles[STY_IME_COLOR].szValue, FOREGROUND_LAYER, &rgb, true); // IME foregr + Style_StrGetColor(pCurrentStandard->Styles[STY_IME_COLOR].szValue, FOREGROUND_LAYER, &rgb, NULL, true); // IME foregr SciCall_IndicSetFore(_SC_INDIC_IME_INPUT, rgb); SciCall_IndicSetFore(_SC_INDIC_IME_TARGET, rgb); SciCall_IndicSetFore(_SC_INDIC_IME_CONVERTED, rgb); @@ -1497,7 +1497,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) } Style_SetStyles(hwnd, pCurrentStandard->Styles[STY_INDENT_GUIDE].iStyle, pCurrentStandard->Styles[STY_INDENT_GUIDE].szValue); // indent guide - if (Style_StrGetColor(pCurrentStandard->Styles[STY_SEL_TXT].szValue, FOREGROUND_LAYER, &rgb, false)) { // selection fore + if (Style_StrGetColor(pCurrentStandard->Styles[STY_SEL_TXT].szValue, FOREGROUND_LAYER, &rgb, NULL, false)) { // selection fore SciCall_SetElementColour(SC_ELEMENT_SELECTION_TEXT, RGBxA(rgb, SC_ALPHA_OPAQUE)); SciCall_SetElementColour(SC_ELEMENT_SELECTION_ADDITIONAL_TEXT, RGBxA(rgb, SC_ALPHA_OPAQUE)); } @@ -1508,7 +1508,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) rgb = RGB(0xC0, 0xC0, 0xC0); SciCall_SetSelectionLayer(SC_LAYER_UNDER_TEXT); // selection back - if (Style_StrGetColor(pCurrentStandard->Styles[STY_SEL_TXT].szValue, BACKGROUND_LAYER, &rgb, true)) { + if (Style_StrGetColor(pCurrentStandard->Styles[STY_SEL_TXT].szValue, BACKGROUND_LAYER, &rgb, NULL, true)) { Style_StrGetAlpha(pCurrentStandard->Styles[STY_SEL_TXT].szValue, &iValue, true); SciCall_SetElementColour(SC_ELEMENT_SELECTION_BACK, RGBxA(rgb, iValue)); SciCall_SetElementColour(SC_ELEMENT_SELECTION_ADDITIONAL_BACK, RGBxA(rgb, iValue * 2 / 3)); @@ -1543,7 +1543,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) // whitespace colors rgb = RGB(0, 0, 0); - if (Style_StrGetColor(pCurrentStandard->Styles[STY_WHITESPACE].szValue, FOREGROUND_LAYER, &rgb, false)) { + if (Style_StrGetColor(pCurrentStandard->Styles[STY_WHITESPACE].szValue, FOREGROUND_LAYER, &rgb, NULL, false)) { Style_PrintfCchColor(wch, COUNTOF(wch), L"; ", FOREGROUND_LAYER, rgb); StringCchCat(wchSpecificStyle, COUNTOF(wchSpecificStyle), wch); @@ -1558,7 +1558,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) } rgb = RGB(0, 0, 0); - if (Style_StrGetColor(pCurrentStandard->Styles[STY_WHITESPACE].szValue, BACKGROUND_LAYER, &rgb, true)) { + if (Style_StrGetColor(pCurrentStandard->Styles[STY_WHITESPACE].szValue, BACKGROUND_LAYER, &rgb, NULL, true)) { Style_PrintfCchColor(wch, COUNTOF(wch), L"; ", FOREGROUND_LAYER, rgb); StringCchCat(wchSpecificStyle, COUNTOF(wchSpecificStyle), wch); @@ -1627,7 +1627,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) } // caret fore rgb = GetModeTextColor(UseDarkMode()); - if (Style_StrGetColor(pCurrentStandard->Styles[STY_CARET].szValue, FOREGROUND_LAYER, &rgb, false)) { + if (Style_StrGetColor(pCurrentStandard->Styles[STY_CARET].szValue, FOREGROUND_LAYER, &rgb, NULL, false)) { Style_PrintfCchColor(wch, COUNTOF(wch), L"; ", FOREGROUND_LAYER, rgb); StringCchCat(wchSpecificStyle,COUNTOF(wchSpecificStyle),wch); } @@ -1873,10 +1873,10 @@ void Style_SetUrlHotSpot(HWND hwnd) } COLORREF activeFG = RGB(0x00, 0x00, 0xE0); - Style_StrGetColor(lpszStyleHotSpot, FOREGROUND_LAYER, &activeFG, false); + Style_StrGetColor(lpszStyleHotSpot, FOREGROUND_LAYER, &activeFG, NULL, false); COLORREF inactiveFG = RGB(0x00, 0x60, 0xB0); - Style_StrGetColor(lpszStyleHotSpot, BACKGROUND_LAYER, &inactiveFG, false); + Style_StrGetColor(lpszStyleHotSpot, BACKGROUND_LAYER, &inactiveFG, NULL, false); int iValue = SC_ALPHA_OPAQUE; Style_StrGetAlpha(lpszStyleHotSpot, &iValue, true); @@ -1944,11 +1944,11 @@ void Style_SetMultiEdgeLine(const int colVec[], const size_t count) Globals.iWrapCol = iLongLineLimit; // long line limit should be explicit wrap column too if (mLongLineMode == EDGE_BACKGROUND) { - if (!Style_StrGetColor(GetCurrentStdLexer()->Styles[STY_LONG_LN_MRK].szValue, BACKGROUND_LAYER, &rgb, false)) { // edge back + if (!Style_StrGetColor(GetCurrentStdLexer()->Styles[STY_LONG_LN_MRK].szValue, BACKGROUND_LAYER, &rgb, NULL, false)) { // edge back rgb = GetSysColor(COLOR_3DSHADOW); } } else { - if (!Style_StrGetColor(GetCurrentStdLexer()->Styles[STY_LONG_LN_MRK].szValue, FOREGROUND_LAYER, &rgb, false)) { // edge fore + if (!Style_StrGetColor(GetCurrentStdLexer()->Styles[STY_LONG_LN_MRK].szValue, FOREGROUND_LAYER, &rgb, NULL, false)) { // edge fore rgb = GetSysColor(COLOR_3DLIGHT); } } @@ -1991,7 +1991,7 @@ void Style_HighlightCurrentLine(HWND hwnd, int iHiLitCurLn) LPCWSTR szValue = GetCurrentStdLexer()->Styles[STY_CUR_LN].szValue; COLORREF rgb; - if (!Style_StrGetColor(szValue, (backgrColor ? BACKGROUND_LAYER : FOREGROUND_LAYER), &rgb, false)) { + if (!Style_StrGetColor(szValue, (backgrColor ? BACKGROUND_LAYER : FOREGROUND_LAYER), &rgb, NULL, false)) { rgb = (backgrColor ? RGB(0xFF, 0xFF, 0x00) : RGB(0xC2, 0xC0, 0xC3)); } @@ -2079,25 +2079,25 @@ void Style_SetMargin(HWND hwnd, LPCWSTR lpszStyle) /// iStyle == STYLE_LINENUMBE COLORREF colorRead; // foreground - if (!Style_StrGetColor(lpszStyle, FOREGROUND_LAYER, &colorRead, false)) { + if (!Style_StrGetColor(lpszStyle, FOREGROUND_LAYER, &colorRead, NULL, false)) { colorRead = GetModeTextColor(UseDarkMode()); } COLORREF const clrLineNumFore = colorRead; SciCall_StyleSetFore(STYLE_LINENUMBER, clrLineNumFore); // background - if (!Style_StrGetColor(lpszStyle, BACKGROUND_LAYER, &colorRead, false)) { + if (!Style_StrGetColor(lpszStyle, BACKGROUND_LAYER, &colorRead, NULL, false)) { colorRead = GetModeBtnfaceColor(UseDarkMode()); } COLORREF const clrMarginBack = colorRead; COLORREF fldHiLight = clrLineNumFore; const WCHAR* wchHighlightStyleStrg = GetCurrentStdLexer()->Styles[STY_SEL_TXT].szValue; - Style_StrGetColor(wchHighlightStyleStrg, FOREGROUND_LAYER, &fldHiLight, true); + Style_StrGetColor(wchHighlightStyleStrg, FOREGROUND_LAYER, &fldHiLight, NULL, true); COLORREF clrFoldMarginBack = clrMarginBack; const WCHAR* wchDefaultStyleStrg = GetCurrentStdLexer()->Styles[STY_DEFAULT].szValue; - Style_StrGetColor(wchDefaultStyleStrg, BACKGROUND_LAYER, &clrFoldMarginBack, true); + Style_StrGetColor(wchDefaultStyleStrg, BACKGROUND_LAYER, &clrFoldMarginBack, NULL, true); // --- Line Numbers --- @@ -2117,12 +2117,12 @@ void Style_SetMargin(HWND hwnd, LPCWSTR lpszStyle) /// iStyle == STYLE_LINENUMBE const WCHAR* const wchBookMarkStyleStrg = GetCurrentStdLexer()->Styles[STY_BOOK_MARK].szValue; colorRead = clrLineNumFore; - Style_StrGetColor(wchBookMarkStyleStrg, FOREGROUND_LAYER, &colorRead, false); + Style_StrGetColor(wchBookMarkStyleStrg, FOREGROUND_LAYER, &colorRead, NULL, false); COLORREF const clrBookMarkFore = colorRead; colorRead = clrMarginBack; - Style_StrGetColor(wchBookMarkStyleStrg, BACKGROUND_LAYER, &colorRead, false); + Style_StrGetColor(wchBookMarkStyleStrg, BACKGROUND_LAYER, &colorRead, NULL, false); // adjust background color by alpha in case of show margin int alpha = SC_ALPHA_OPAQUE; Style_StrGetAlpha(wchBookMarkStyleStrg, &alpha, true); @@ -2152,7 +2152,7 @@ void Style_SetMargin(HWND hwnd, LPCWSTR lpszStyle) /// iStyle == STYLE_LINENUMBE COLORREF color; for (int m = MARKER_NP3_1; m < MARKER_NP3_BOOKMARK; ++m) { SciCall_MarkerDefine(m, (Settings.FocusViewMarkerMode & FVMM_LN_BACKGR) ? SC_MARK_BACKGROUND : SC_MARK_BOOKMARK); - Style_StrGetColor(WordBookMarks[m], BACKGROUND_LAYER, &color, true); + Style_StrGetColor(WordBookMarks[m], BACKGROUND_LAYER, &color, NULL, true); SciCall_MarkerSetForeTranslucent(m, RGBxA(color, SC_ALPHA_OPAQUE)); SciCall_MarkerSetBackTranslucent(m, RGBxA(color, alpha)); // 'alpha' no meaning for SC_MARK_BACKGROUND } @@ -2168,11 +2168,11 @@ void Style_SetMargin(HWND hwnd, LPCWSTR lpszStyle) /// iStyle == STYLE_LINENUMBE const WCHAR* const wchChgHistMrkModifiedStyleStrg = GetCurrentStdLexer()->Styles[STY_CHGHIST_MODIFIED].szValue; colorRead = clrBookMarkFore; - if (Style_StrGetColor(wchChgHistMrkModifiedStyleStrg, FOREGROUND_LAYER, &colorRead, false)) { + if (Style_StrGetColor(wchChgHistMrkModifiedStyleStrg, FOREGROUND_LAYER, &colorRead, NULL, false)) { SciCall_MarkerSetFore(SC_MARKNUM_HISTORY_MODIFIED, colorRead); } colorRead = clrMarginBack; - Style_StrGetColor(wchChgHistMrkModifiedStyleStrg, BACKGROUND_LAYER, &colorRead, false); + Style_StrGetColor(wchChgHistMrkModifiedStyleStrg, BACKGROUND_LAYER, &colorRead, NULL, false); // also if not defined, use margin backgr SciCall_MarkerSetBack(SC_MARKNUM_HISTORY_MODIFIED, colorRead); @@ -2184,31 +2184,31 @@ void Style_SetMargin(HWND hwnd, LPCWSTR lpszStyle) /// iStyle == STYLE_LINENUMBE const WCHAR* const wchChgHistMrkSavedStyleStrg = GetCurrentStdLexer()->Styles[STY_CHGHIST_SAVED].szValue; colorRead = clrBookMarkFore; - if (Style_StrGetColor(wchChgHistMrkSavedStyleStrg, FOREGROUND_LAYER, &colorRead, false)) { + if (Style_StrGetColor(wchChgHistMrkSavedStyleStrg, FOREGROUND_LAYER, &colorRead, NULL, false)) { SciCall_MarkerSetFore(SC_MARKNUM_HISTORY_SAVED, colorRead); } colorRead = clrMarginBack; - if (Style_StrGetColor(wchChgHistMrkSavedStyleStrg, BACKGROUND_LAYER, &colorRead, false)) { + if (Style_StrGetColor(wchChgHistMrkSavedStyleStrg, BACKGROUND_LAYER, &colorRead, NULL, false)) { SciCall_MarkerSetBack(SC_MARKNUM_HISTORY_SAVED, colorRead); } const WCHAR* const wchChgHistMrkRev2OrgStyleStrg = GetCurrentStdLexer()->Styles[STY_CHGHIST_REV_TO_ORG].szValue; colorRead = clrBookMarkFore; - if (Style_StrGetColor(wchChgHistMrkRev2OrgStyleStrg, FOREGROUND_LAYER, &colorRead, false)) { + if (Style_StrGetColor(wchChgHistMrkRev2OrgStyleStrg, FOREGROUND_LAYER, &colorRead, NULL, false)) { SciCall_MarkerSetFore(SC_MARKNUM_HISTORY_REVERTED_TO_ORIGIN, colorRead); } colorRead = clrMarginBack; - if (Style_StrGetColor(wchChgHistMrkRev2OrgStyleStrg, BACKGROUND_LAYER, &colorRead, false)) { + if (Style_StrGetColor(wchChgHistMrkRev2OrgStyleStrg, BACKGROUND_LAYER, &colorRead, NULL, false)) { SciCall_MarkerSetBack(SC_MARKNUM_HISTORY_REVERTED_TO_ORIGIN, colorRead); } const WCHAR* const wchChgHistMrkRev2ModStyleStrg = GetCurrentStdLexer()->Styles[STY_CHGHIST_REV_TO_MOD].szValue; colorRead = clrBookMarkFore; - if (Style_StrGetColor(wchChgHistMrkRev2ModStyleStrg, FOREGROUND_LAYER, &colorRead, false)) { + if (Style_StrGetColor(wchChgHistMrkRev2ModStyleStrg, FOREGROUND_LAYER, &colorRead, NULL, false)) { SciCall_MarkerSetFore(SC_MARKNUM_HISTORY_REVERTED_TO_MODIFIED, colorRead); } colorRead = clrMarginBack; - if (Style_StrGetColor(wchChgHistMrkRev2ModStyleStrg, BACKGROUND_LAYER, &colorRead, false)) { + if (Style_StrGetColor(wchChgHistMrkRev2ModStyleStrg, BACKGROUND_LAYER, &colorRead, NULL, false)) { SciCall_MarkerSetBack(SC_MARKNUM_HISTORY_REVERTED_TO_MODIFIED, colorRead); } @@ -3220,11 +3220,14 @@ void Style_AppendWeightAttribute(LPWSTR lpszWeight, int cchSize, int fontWeight) // // Style_StrGetColor() // -bool Style_StrGetColor(LPCWSTR lpszStyle, COLOR_LAYER layer, COLORREF *rgb, bool useDefault) { - - bool const bFGLayer = (layer == FOREGROUND_LAYER); - bool bIsDefined = false; - const WCHAR *const pItem = bFGLayer ? L"fore:" : L"back:"; +bool Style_StrGetColor(LPCWSTR lpszStyle, COLOR_LAYER layer, COLORREF* rgb, COLORREF* rgbOrig, bool useDefault) +{ + bool const bFGLayer = (layer == FOREGROUND_LAYER); + //~COLORREF const colorDefault = bFGLayer ? GetModeTextColor(UseDarkMode()) : GetModeBkColor(UseDarkMode()); + COLORREF const colorDefault = bFGLayer ? SciCall_StyleGetFore(STYLE_DEFAULT) : SciCall_StyleGetBack(STYLE_DEFAULT); //~ SCI maybe not initialized + COLORREF color = rgbOrig ? *rgbOrig : (rgb ? *rgb : colorDefault); + bool bIsDefined = false; + const WCHAR* const pItem = bFGLayer ? L"fore:" : L"back:"; WCHAR *p = StrStr(lpszStyle, pItem); if (p) { WCHAR tch[BUFSIZE_STYLE_VALUE] = { L'\0' }; @@ -3240,19 +3243,24 @@ bool Style_StrGetColor(LPCWSTR lpszStyle, COLOR_LAYER layer, COLORREF *rgb, bool unsigned int iValue = 0; if (swscanf_s(tch, L"%x", &iValue) == 1) { - *rgb = RGB((iValue & 0xFF0000) >> 16, (iValue & 0xFF00) >> 8, iValue & 0xFF); + color = RGB((iValue & 0xFF0000) >> 16, (iValue & 0xFF00) >> 8, iValue & 0xFF); bIsDefined = true; } } - // no colordef bIsDefined - use default as fallback ? - if (!bIsDefined && useDefault) - { - //~*rgb = bFGLayer ? GetModeTextColor(UseDarkMode()) : GetModeBkColor(UseDarkMode()); - *rgb = bFGLayer ? SciCall_StyleGetFore(STYLE_DEFAULT) : SciCall_StyleGetBack(STYLE_DEFAULT); //~ SCI maybe not initialized + + if (!bIsDefined && useDefault) { + color = colorDefault; //~ don't: bIsDefined = true; } + + if (rgbOrig) { + *rgbOrig = color; + } if (bFGLayer && UseDarkMode()) { - *rgb = ContrastColor(*rgb, Settings2.DarkModeHiglightContrast); + color = ContrastColor(color, Settings2.DarkModeHiglightContrast); + } + if (rgb) { + *rgb = color; } return bIsDefined; @@ -3460,10 +3468,11 @@ void Style_CopyStyles_IfNotDefined(LPCWSTR lpszStyleSrc, LPWSTR lpszStyleDest, i } // foreground color - if (Style_StrGetColor(lpszStyleDest, FOREGROUND_LAYER, &dColor, false)) { + if (Style_StrGetColor(lpszStyleDest, FOREGROUND_LAYER, NULL, &dColor, false)) { Style_PrintfCchColor(tch, COUNTOF(tch), L"; ", FOREGROUND_LAYER, dColor); StringCchCat(szTmpStyle, COUNTOF(szTmpStyle), tch); - } else if (Style_StrGetColor(lpszStyleSrc, FOREGROUND_LAYER, &dColor, false)) { + } + else if (Style_StrGetColor(lpszStyleSrc, FOREGROUND_LAYER, NULL, &dColor, false)) { Style_PrintfCchColor(tch, COUNTOF(tch), L"; ", FOREGROUND_LAYER, dColor); StringCchCat(szTmpStyle, COUNTOF(szTmpStyle), tch); } @@ -3471,10 +3480,11 @@ void Style_CopyStyles_IfNotDefined(LPCWSTR lpszStyleSrc, LPWSTR lpszStyleDest, i // ######## attributes not defined by Font Selection Dialog ######## // background color - if (Style_StrGetColor(lpszStyleDest, BACKGROUND_LAYER, &dColor, false)) { + if (Style_StrGetColor(lpszStyleDest, BACKGROUND_LAYER, NULL, &dColor, false)) { Style_PrintfCchColor(tch, COUNTOF(tch), L"; ", BACKGROUND_LAYER, dColor); StringCchCat(szTmpStyle, COUNTOF(szTmpStyle), tch); - } else if (Style_StrGetColor(lpszStyleSrc, BACKGROUND_LAYER, &dColor, false)) { + } + else if (Style_StrGetColor(lpszStyleSrc, BACKGROUND_LAYER, NULL, &dColor, false)) { Style_PrintfCchColor(tch, COUNTOF(tch), L"; ", BACKGROUND_LAYER, dColor); StringCchCat(szTmpStyle, COUNTOF(szTmpStyle), tch); } @@ -3636,7 +3646,7 @@ bool Style_SelectFont(HWND hwnd, LPWSTR lpszStyle, int cchStyle, LPCWSTR sLexerN int const iQuality = MapSciToWinFontQuality(Settings2.SciFontQuality); COLORREF fgColor = 0L; - Style_StrGetColor(lpszStyle, FOREGROUND_LAYER, &fgColor, true); + Style_StrGetColor(lpszStyle, FOREGROUND_LAYER, &fgColor, NULL, true); // -------------------------------------------------------------------------- @@ -3767,7 +3777,7 @@ bool Style_SelectFont(HWND hwnd, LPWSTR lpszStyle, int cchStyle, LPCWSTR sLexerN } COLORREF fgColorDefault = 0L; - Style_StrGetColor(L"", FOREGROUND_LAYER, &fgColorDefault, true); + Style_StrGetColor(L"", FOREGROUND_LAYER, &fgColorDefault, NULL, true); if (cf.rgbColors != fgColorDefault) { WCHAR fgColorStr[32] = { L'\0' }; Style_PrintfCchColor(fgColorStr, COUNTOF(fgColorStr), L"; ", FOREGROUND_LAYER, cf.rgbColors); @@ -3795,7 +3805,7 @@ bool Style_SelectColor(HWND hwnd,bool bForeGround,LPWSTR lpszStyle,int cchStyle, COLOR_LAYER const layer = (bForeGround ? FOREGROUND_LAYER : BACKGROUND_LAYER); COLORREF dRGBResult; - Style_StrGetColor(lpszStyle, layer, &dRGBResult, true); + Style_StrGetColor(lpszStyle, layer, &dRGBResult, NULL, true); CHOOSECOLOR cc = { sizeof(CHOOSECOLOR) }; cc.hwndOwner = hwnd; @@ -3826,14 +3836,14 @@ bool Style_SelectColor(HWND hwnd,bool bForeGround,LPWSTR lpszStyle,int cchStyle, Style_PrintfCchColor(tch, COUNTOF(tch), L"; ", FOREGROUND_LAYER, dRGBResult); StringCchCat(szNewStyle,COUNTOF(szNewStyle),tch); - if (Style_StrGetColor(lpszStyle, BACKGROUND_LAYER, &dColor, false)) { + if (Style_StrGetColor(lpszStyle, BACKGROUND_LAYER, &dColor, NULL, false)) { Style_PrintfCchColor(tch, COUNTOF(tch), L"; ", BACKGROUND_LAYER, dColor); StringCchCat(szNewStyle,COUNTOF(szNewStyle),tch); } } else { // set background - if (Style_StrGetColor(lpszStyle, FOREGROUND_LAYER, &dColor, false)) { + if (Style_StrGetColor(lpszStyle, FOREGROUND_LAYER, &dColor, NULL, false)) { Style_PrintfCchColor(tch, COUNTOF(tch), L"; ", FOREGROUND_LAYER, dColor); StringCchCat(szNewStyle,COUNTOF(szNewStyle),tch); } @@ -3936,22 +3946,22 @@ void Style_SetStyles(HWND hwnd, const int iStyle, LPCWSTR lpszStyle) COLORREF dColor = 0L; // Foregr - if (Style_StrGetColor(lpszStyle, FOREGROUND_LAYER, &dColor, false)) { + if (Style_StrGetColor(lpszStyle, FOREGROUND_LAYER, &dColor, NULL, false)) { SciCall_StyleSetFore(iStyle, dColor); } else if (bIsDefaultStyle) { SciCall_StyleSetFore(iStyle, GetModeTextColor(UseDarkMode())); } else { // fallback: SCI default - Style_StrGetColor(lpszStyle, FOREGROUND_LAYER, &dColor, true); + Style_StrGetColor(lpszStyle, FOREGROUND_LAYER, &dColor, NULL, true); SciCall_StyleSetFore(iStyle, dColor); } // Backgr - if (Style_StrGetColor(lpszStyle, BACKGROUND_LAYER, &dColor, false)) { + if (Style_StrGetColor(lpszStyle, BACKGROUND_LAYER, &dColor, NULL, false)) { SciCall_StyleSetBack(iStyle, dColor); } else if (bIsDefaultStyle) { SciCall_StyleSetBack(iStyle, GetModeBkColor(UseDarkMode())); } else { // fallback: SCI default - Style_StrGetColor(lpszStyle, BACKGROUND_LAYER, &dColor, true); + Style_StrGetColor(lpszStyle, BACKGROUND_LAYER, &dColor, NULL, true); SciCall_StyleSetBack(iStyle, dColor); } @@ -4385,7 +4395,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd, UINT umsg, WPARAM wPar MakeBitmapButton(hwnd, IDC_PREVSTYLE, IDB_PREV, -1, -1); MakeBitmapButton(hwnd, IDC_NEXTSTYLE, IDB_NEXT, -1, -1); - UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, 0); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, LOWORD(wParam)); } return TRUE; @@ -4769,11 +4779,11 @@ CASE_WM_CTLCOLOR_SET: GetDlgItemText(hwnd, IDC_STYLEEDIT, tch, COUNTOF(tch)); COLORREF cr = COLORREF_MAX; // SciCall_StyleGetFore(STYLE_DEFAULT); - Style_StrGetColor(tch, FOREGROUND_LAYER, &cr, true); + Style_StrGetColor(tch, FOREGROUND_LAYER, &cr, NULL, true); MakeColorPickButton(hwnd, IDC_STYLEFORE, Globals.hInstance, cr); cr = COLORREF_MAX; // SciCall_StyleGetBack(STYLE_DEFAULT); - Style_StrGetColor(tch, BACKGROUND_LAYER, &cr, true); + Style_StrGetColor(tch, BACKGROUND_LAYER, &cr, NULL, true); MakeColorPickButton(hwnd, IDC_STYLEBACK, Globals.hInstance, cr); } } @@ -5017,10 +5027,8 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR case WM_DPICHANGED: { - - UpdateWindowLayoutForDPI(hwnd, (RECT *)lParam, 0); - UINT const dpi = LOWORD(wParam); + UpdateWindowLayoutForDPI(hwnd, (RECT*)lParam, dpi); SHFILEINFO shfi = { 0 }; UINT const flagIconSize = (dpi >= LargeIconDPI()) ? SHGFI_LARGEICON : SHGFI_SMALLICON; ListView_SetImageList(hwndLV, diff --git a/src/Styles.h b/src/Styles.h index e509c06e7..e9b4f615c 100644 --- a/src/Styles.h +++ b/src/Styles.h @@ -91,7 +91,7 @@ bool Style_StrGetSizeStr(LPCWSTR lpszStyle,LPWSTR lpszSize,int cchSize); void Style_AppendSizeAttribute(LPWSTR lpszSize, int cchSize, const float fFontSize, const float fBaseFontSize); bool Style_StrGetWeightValue(LPCWSTR lpszWeight, int *weight); void Style_AppendWeightAttribute(LPWSTR lpszWeight, int cchSize, int fontWeight); -bool Style_StrGetColor(LPCWSTR lpszStyle, COLOR_LAYER layer, COLORREF *rgb, bool useDefault); +bool Style_StrGetColor(LPCWSTR lpszStyle, COLOR_LAYER layer, COLORREF *rgb, COLORREF *rgbOrig, bool useDefault); bool Style_StrGetStrokeWidth(HWND hwnd, int indicID, LPCWSTR lpszStyle, int *piStrokeWidth); bool Style_StrGetCase(LPCWSTR lpszStyle, int *i); bool Style_StrGetAlpha(LPCWSTR lpszStyle, int* iOutValue, bool bAlpha1st); diff --git a/src/crypto/crypto.c b/src/crypto/crypto.c index 22f916e7a..105285ab1 100644 --- a/src/crypto/crypto.c +++ b/src/crypto/crypto.c @@ -156,7 +156,7 @@ INT_PTR CALLBACK SetKeysDlgProc(HWND hDlg, UINT umsg, WPARAM wParam, LPARAM lPar return TRUE; case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hDlg, (RECT*)lParam, 0); + UpdateWindowLayoutForDPI(hDlg, (RECT*)lParam, (UINT)HIWORD(wParam)); return TRUE; //#define WM_CTLCOLORMSGBOX 0x0132 @@ -352,7 +352,7 @@ INT_PTR CALLBACK GetKeysDlgProc(HWND hDlg, UINT umsg, WPARAM wParam, LPARAM lPar return !0; case WM_DPICHANGED: - UpdateWindowLayoutForDPI(hDlg, (RECT*)lParam, 0); + UpdateWindowLayoutForDPI(hDlg, (RECT*)lParam, (UINT)HIWORD(wParam)); return !0; #ifdef D_NP3_WIN10_DARK_MODE