Hugh McMaster : regedit: Use a separate dialog proc function for string data types.
Alexandre Julliard
julliard at winehq.org
Thu Jul 21 17:04:08 CDT 2022
Module: wine
Branch: master
Commit: b00a4b66b93e24e00c6638fd0b18716908885d06
URL: https://gitlab.winehq.org/wine/wine/-/commit/b00a4b66b93e24e00c6638fd0b18716908885d06
Author: Hugh McMaster <hugh.mcmaster at outlook.com>
Date: Fri Jul 8 10:44:21 2022 +1000
regedit: Use a separate dialog proc function for string data types.
Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
programs/regedit/edit.c | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/programs/regedit/edit.c b/programs/regedit/edit.c
index 4cb48799090..d668425b137 100644
--- a/programs/regedit/edit.c
+++ b/programs/regedit/edit.c
@@ -81,6 +81,35 @@ static void WINAPIV error_code_messagebox(HWND hwnd, unsigned int msg_id, ...)
va_end(ap);
}
+static INT_PTR CALLBACK modify_string_dlgproc(HWND hwndDlg, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+ HWND hwndValue;
+ unsigned int len;
+
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ SetDlgItemTextW(hwndDlg, IDC_VALUE_NAME, editValueName);
+ SetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, stringValueData);
+ return TRUE;
+ case WM_COMMAND:
+ switch (LOWORD(wparam))
+ {
+ case IDOK:
+ hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_DATA);
+ len = GetWindowTextLengthW(hwndValue);
+ stringValueData = realloc(stringValueData, (len + 1) * sizeof(WCHAR));
+ if (!GetWindowTextW(hwndValue, stringValueData, len + 1))
+ *stringValueData = 0;
+ /* fall through */
+ case IDCANCEL:
+ EndDialog(hwndDlg, wparam);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
static BOOL change_dword_base(HWND hwndDlg, BOOL toHex)
{
WCHAR buf[128];
@@ -268,7 +297,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
if(!(stringValueData = read_value(hwnd, hKey, valueName, &type, &len))) goto done;
if ( (type == REG_SZ) || (type == REG_EXPAND_SZ) ) {
- if (DialogBoxW(0, MAKEINTRESOURCEW(IDD_EDIT_STRING), hwnd, modify_dlgproc) == IDOK) {
+ if (DialogBoxW(0, MAKEINTRESOURCEW(IDD_EDIT_STRING), hwnd, modify_string_dlgproc) == IDOK) {
lRet = RegSetValueExW(hKey, valueName, 0, type, (LPBYTE)stringValueData, (lstrlenW(stringValueData) + 1) * sizeof(WCHAR));
if (lRet == ERROR_SUCCESS) result = TRUE;
else error_code_messagebox(hwnd, IDS_SET_VALUE_FAILED);
More information about the wine-cvs
mailing list