From 88ac6cce9b9c8e0e437eea2f800fb7a6e2de798f Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Sat, 29 May 2021 12:05:42 +0200 Subject: [PATCH] +chg: Win10 Release-ID as string (allows 20H2 or 21H1) +fix: F/R Dialog regression: allow replace in selection (if selection not empty) --- src/Edit.c | 8 +++----- src/Helpers.c | 33 ++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index dc1243626..2afa898cf 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -5899,11 +5899,9 @@ static void _ShowZeroLengthCallTip(DocPos iPosition) // static bool _EnableFRDlgCtrls(HWND hwnd) { - //bool const bEmptyFnd = (ComboBox_GetTextLengthEx(hwnd, IDC_FINDTEXT) == 0 || ComboBox_GetCurSelEx(hwnd, IDC_FINDTEXT) != CB_ERR); - //bool const bEmptyRpl = (ComboBox_GetTextLengthEx(hwnd, IDC_REPLACETEXT) == 0 || ComboBox_GetCurSelEx(hwnd, IDC_REPLACETEXT) != CB_ERR); - bool const bEmptyFnd = ComboBox_GetTextLengthEx(hwnd, IDC_FINDTEXT) == 0; - bool const bEmptyRpl = ComboBox_GetTextLengthEx(hwnd, IDC_REPLACETEXT) == 0; - bool const bEmptySel = !(SciCall_IsSelectionEmpty() || Sci_IsMultiOrRectangleSelection()); + bool const bEmptyFnd = ComboBox_GetTextLengthEx(hwnd, IDC_FINDTEXT) == 0 /*|| ComboBox_GetCurSelEx(hwnd, IDC_FINDTEXT) != CB_ERR)*/; + bool const bEmptyRpl = ComboBox_GetTextLengthEx(hwnd, IDC_REPLACETEXT) == 0 /*|| ComboBox_GetCurSelEx(hwnd, IDC_REPLACETEXT) != CB_ERR)*/; + bool const bEmptySel = (SciCall_IsSelectionEmpty() || Sci_IsMultiOrRectangleSelection()); DialogEnableControl(hwnd, IDOK, !bEmptyFnd); DialogEnableControl(hwnd, IDC_FINDPREV, !bEmptyFnd); diff --git a/src/Helpers.c b/src/Helpers.c index 3524158bb..9e084f863 100644 --- a/src/Helpers.c +++ b/src/Helpers.c @@ -213,32 +213,35 @@ static void _GetTrueWindowsVersion() #endif // ---------------------------------------------------------------------------- -// https://docs.microsoft.com/en-us/windows/release-information/ +// https://docs.microsoft.com/en-US/windows/release-health/release-information // ---------------------------------------------------------------------------- -static DWORD _Win10BuildToReleaseId(DWORD build) +static LPCWSTR _Win10BuildToReleaseId(DWORD build) { - if (build >= 19042) { - return 2009; + static LPCWSTR _wchpReleaseID = L"1507"; // 10240 + if (build >= 19043) { + _wchpReleaseID = L"21H1"; + } else if (build >= 19042) { + _wchpReleaseID = L"20H2"; } else if (build >= 19041) { - return 2004; + _wchpReleaseID = L"2004"; } else if (build >= 18363) { - return 1909; + _wchpReleaseID = L"1909"; } else if (build >= 18362) { - return 1903; + _wchpReleaseID = L"1903 (EoS)"; } else if (build >= 17763) { - return 1809; + _wchpReleaseID = L"1809"; } else if (build >= 17134) { - return 1803; + _wchpReleaseID = L"1803 (EoS)"; } else if (build >= 16299) { - return 1709; + _wchpReleaseID = L"1709 (EoS)"; } else if (build >= 15063) { - return 1809; + _wchpReleaseID = L"1703 (EoS)"; } else if (build >= 14393) { - return 1607; + _wchpReleaseID = L"1607"; } else if (build >= 10586) { - return 1511; + _wchpReleaseID = L"1511 (EoS)"; } - return 0; // 10240 + return _wchpReleaseID; } // ---------------------------------------------------------------------------- @@ -262,7 +265,7 @@ void GetWinVersionString(LPWSTR szVersionStr, size_t cchVersionStr) if (IsWindows10OrGreater()) { WCHAR win10ver[80] = { L'\0' }; - StringCchPrintf(win10ver, COUNTOF(win10ver), L" Version %i (Build %i)", + StringCchPrintf(win10ver, COUNTOF(win10ver), L" Version %s (Build %lu)", _Win10BuildToReleaseId(Globals.WindowsBuildNumber), Globals.WindowsBuildNumber); StringCchCat(szVersionStr, cchVersionStr, win10ver); }