Commit 93199da8 authored by Hugh McMaster's avatar Hugh McMaster Committed by Alexandre Julliard

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

parent 89bbd132
...@@ -184,15 +184,26 @@ static INT_PTR CALLBACK modify_string_dlgproc(HWND hwndDlg, UINT msg, WPARAM wpa ...@@ -184,15 +184,26 @@ static INT_PTR CALLBACK modify_string_dlgproc(HWND hwndDlg, UINT msg, WPARAM wpa
return FALSE; 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; UINT64 val;
if (!GetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, buf, ARRAY_SIZE(buf))) return FALSE; len = GetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, buf, ARRAY_SIZE(buf));
if (!swscanf(buf, toHex ? L"%I64u" : L"%I64x", &val)) return FALSE; if (!len) SetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, L"0");
wsprintfW(buf, toHex ? L"%I64x" : L"%I64u", val);
return SetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, buf); 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) 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 ...@@ -217,10 +228,10 @@ static INT_PTR CALLBACK modify_dword_dlgproc(HWND hwndDlg, UINT msg, WPARAM wpar
switch (LOWORD(wparam)) switch (LOWORD(wparam))
{ {
case IDC_DWORD_HEX: case IDC_DWORD_HEX:
if (isDecimal && change_dword_base(hwndDlg, TRUE)) isDecimal = FALSE; change_dword_base(hwndDlg, TRUE);
break; break;
case IDC_DWORD_DEC: case IDC_DWORD_DEC:
if (!isDecimal && change_dword_base(hwndDlg, FALSE)) isDecimal = TRUE; change_dword_base(hwndDlg, FALSE);
break; break;
case IDOK: case IDOK:
params = (struct edit_params *)GetWindowLongPtrW(hwndDlg, DWLP_USER); params = (struct edit_params *)GetWindowLongPtrW(hwndDlg, DWLP_USER);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment