Hugh McMaster : regedit: Use zero as a default for REG_DWORD and REG_QWORD values.

Alexandre Julliard julliard at winehq.org
Wed Jul 27 16:15:58 CDT 2022


Module: wine
Branch: master
Commit: 93199da8c3381eafc75bbebc5ea3a80d7ac426ef
URL:    https://gitlab.winehq.org/wine/wine/-/commit/93199da8c3381eafc75bbebc5ea3a80d7ac426ef

Author: Hugh McMaster <hugh.mcmaster at outlook.com>
Date:   Wed Jul 27 17:12:38 2022 +1000

regedit: Use zero as a default for REG_DWORD and REG_QWORD values.

---

 programs/regedit/edit.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/programs/regedit/edit.c b/programs/regedit/edit.c
index 20a0c32adda..79151ee1af6 100644
--- a/programs/regedit/edit.c
+++ b/programs/regedit/edit.c
@@ -184,15 +184,26 @@ static INT_PTR CALLBACK modify_string_dlgproc(HWND hwndDlg, UINT msg, WPARAM wpa
     return FALSE;
 }
 
-static BOOL change_dword_base(HWND hwndDlg, BOOL toHex)
+static void change_dword_base(HWND hwndDlg, BOOL toHex)
 {
-    WCHAR buf[128];
+    WCHAR buf[64];
+    unsigned int len;
     UINT64 val;
 
-    if (!GetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, buf, ARRAY_SIZE(buf))) return FALSE;
-    if (!swscanf(buf, toHex ? L"%I64u" : L"%I64x", &val)) return FALSE;
-    wsprintfW(buf, toHex ? L"%I64x" : L"%I64u", val);
-    return SetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, buf);
+    len = GetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, buf, ARRAY_SIZE(buf));
+    if (!len) SetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, L"0");
+
+    if ((isDecimal && !toHex) || (!isDecimal && toHex))
+        return;
+
+    if (len)
+    {
+        swscanf(buf, toHex ? L"%I64u" : L"%I64x", &val);
+        swprintf(buf, ARRAY_SIZE(buf), toHex ? L"%I64x" : L"%I64u", val);
+        SetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, buf);
+    }
+
+    isDecimal = !toHex;
 }
 
 static INT_PTR CALLBACK modify_dword_dlgproc(HWND hwndDlg, UINT msg, WPARAM wparam, LPARAM lparam)
@@ -217,10 +228,10 @@ static INT_PTR CALLBACK modify_dword_dlgproc(HWND hwndDlg, UINT msg, WPARAM wpar
         switch (LOWORD(wparam))
         {
         case IDC_DWORD_HEX:
-	    if (isDecimal && change_dword_base(hwndDlg, TRUE)) isDecimal = FALSE;
+	    change_dword_base(hwndDlg, TRUE);
             break;
         case IDC_DWORD_DEC:
-	    if (!isDecimal && change_dword_base(hwndDlg, FALSE)) isDecimal = TRUE;
+	    change_dword_base(hwndDlg, FALSE);
             break;
         case IDOK:
             params = (struct edit_params *)GetWindowLongPtrW(hwndDlg, DWLP_USER);




More information about the wine-cvs mailing list