On December 24, 2003 06:32 pm, Zimler Attila wrote:
I think I could help with implementing write support in regedit, as I
think nothing special about windows' graphics programming is need to
know. (Sound's link a task whith I can help as a newbie.)
Yes, you are correct.
Could you assign a subtask of it, and explain it a little?
Yes, I can. In fact, I have a little bit of work in my tree that
hasn't been submitted yet. However, now I'm in a hurry to go to
my parents for Christams eve, so I'll have to do it tomorrow.
--
Dimi.
P.S. I've attached what I have in my tree.
Index: programs/regedit/En.rc
===================================================================
RCS file: /var/cvs/wine/programs/regedit/En.rc,v
retrieving revision 1.3
diff -u -r1.3 En.rc
--- programs/regedit/En.rc 3 Dec 2003 20:25:24 -0000 1.3
+++ programs/regedit/En.rc 13 Dec 2003 07:28:22 -0000
@@ -132,6 +132,21 @@
DEFPUSHBUTTON "Cancel",IDCANCEL,175,60,30,11,WS_GROUP
END
+IDD_EDIT_DWORD DIALOG DISCARDABLE 22, 17, 210, 100
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "Edit String"
+FONT 8, "System"
+BEGIN
+ LTEXT "Value name:",IDC_STATIC,5,5,119,8
+ EDITTEXT IDC_VALUE_NAME,5,15,200,12, WS_BORDER | WS_TABSTOP | WS_DISABLED
+ LTEXT "Value data:",IDC_STATIC,5,30,90,8
+ EDITTEXT IDC_VALUE_DATA,5,40,90,12, WS_BORDER | WS_TABSTOP
+ GROUPBOX "Base", IDC_DWORD_BASE, 120, 30, 85, 37, BS_GROUPBOX
+ AUTORADIOBUTTON "Hexadecimal", IDC_DWORD_HEX, 130, 40, 60, 10, WS_TABSTOP
+ AUTORADIOBUTTON "Decimal", IDC_DWORD_DEC, 130, 52, 60, 10, WS_TABSTOP
+ DEFPUSHBUTTON "OK",IDOK,140,80,30,11,WS_GROUP
+ DEFPUSHBUTTON "Cancel",IDCANCEL,175,80,30,11,WS_GROUP
+END
/*
* String Table
@@ -201,6 +216,8 @@
IDS_BAD_VALUE "Can't query value '%s'"
IDS_UNSUPPORTED_TYPE "Can't edit keys of this type (%ld)"
IDS_TOO_BIG_VALUE "Value is too big (%ld)"
+ IDS_DELETE_BOX_TITLE "Confirm Value Delete"
+ IDS_DELETE_BOX_TEXT "Are you sure you want to delete value '%s'?"
END
/*****************************************************************/
Index: programs/regedit/edit.c
===================================================================
RCS file: /var/cvs/wine/programs/regedit/edit.c,v
retrieving revision 1.3
diff -u -r1.3 edit.c
--- programs/regedit/edit.c 12 Dec 2003 04:08:59 -0000 1.3
+++ programs/regedit/edit.c 13 Dec 2003 07:24:47 -0000
@@ -36,27 +36,42 @@
static const TCHAR* editValueName;
static TCHAR* stringValueData;
-void error(HWND hwnd, INT resId, ...)
+INT vmessagebox(HWND hwnd, INT buttons, INT titleId, INT resId, va_list ap)
{
- va_list ap;
TCHAR title[256];
TCHAR errfmt[1024];
TCHAR errstr[1024];
- HINSTANCE hInstance;
- hInstance = GetModuleHandle(0);
-
- if (!LoadString(hInstance, IDS_ERROR, title, COUNT_OF(title)))
+ if (!LoadString(hInst, titleId, title, COUNT_OF(title)))
lstrcpy(title, "Error");
- if (!LoadString(hInstance, resId, errfmt, COUNT_OF(errfmt)))
+ if (!LoadString(hInst, resId, errfmt, COUNT_OF(errfmt)))
lstrcpy(errfmt, "Unknown error string!");
- va_start(ap, resId);
_vsntprintf(errstr, COUNT_OF(errstr), errfmt, ap);
+
+ return MessageBox(hwnd, errstr, title, buttons);
+}
+
+INT messagebox(HWND hwnd, INT buttons, INT titleId, INT resId, ...)
+{
+ va_list ap;
+ INT result;
+
+ va_start(ap, resId);
+ result = vmessagebox(hwnd, buttons, titleId, resId, ap);
va_end(ap);
- MessageBox(hwnd, errstr, title, MB_OK | MB_ICONERROR);
+ return result;
+}
+
+void error(HWND hwnd, INT resId, ...)
+{
+ va_list ap;
+
+ va_start(ap, resId);
+ vmessagebox(hwnd, MB_OK | MB_ICONERROR, IDS_ERROR, resId, ap);
+ va_end(ap);
}
INT_PTR CALLBACK modify_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
@@ -91,6 +106,38 @@
return FALSE;
}
+INT_PTR CALLBACK modify_dword_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ TCHAR* valueData;
+ HWND hwndValue;
+ int len;
+
+ switch(uMsg) {
+ case WM_INITDIALOG:
+ SetDlgItemText(hwndDlg, IDC_VALUE_NAME, editValueName);
+ SetDlgItemText(hwndDlg, IDC_VALUE_DATA, stringValueData);
+ return TRUE;
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ if ((hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_DATA))) {
+ if ((len = GetWindowTextLength(hwndValue))) {
+ if ((valueData = HeapReAlloc(GetProcessHeap(), 0, stringValueData, (len + 1) * sizeof(TCHAR)))) {
+ stringValueData = valueData;
+ if (!GetWindowText(hwndValue, stringValueData, len + 1))
+ *stringValueData = 0;
+ }
+ }
+ }
+ /* Fall through */
+ case IDCANCEL:
+ EndDialog(hwndDlg, wParam);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName)
{
DWORD valueDataLen;
@@ -123,7 +170,9 @@
if (lRet == ERROR_SUCCESS) result = TRUE;
}
} else if ( type == REG_DWORD ) {
- MessageBox(hwnd, "Can't edit dwords for now", "Error", MB_OK | MB_ICONERROR);
+ if (DialogBox(0, MAKEINTRESOURCE(IDD_EDIT_DWORD), hwnd, modify_dword_dlgproc) == IDOK) {
+ MessageBox(hwnd, "Can't edit dwords for now", "Error", MB_OK | MB_ICONERROR);
+ }
} else {
error(hwnd, IDS_UNSUPPORTED_TYPE, type);
}
@@ -133,4 +182,20 @@
stringValueData = NULL;
return result;
+}
+
+BOOL DeleteValue(HWND hwnd, HKEY hKey, LPCTSTR valueName)
+{
+ LONG lRet;
+
+ if (!hKey || !valueName) return FALSE;
+
+ if (messagebox(hwnd, MB_YESNO | MB_ICONEXCLAMATION, IDS_DELETE_BOX_TITLE, IDS_DELETE_BOX_TEXT, valueName) != IDYES)
+ return FALSE;
+
+ lRet = RegDeleteKey(hKey, valueName);
+ if (lRet != ERROR_SUCCESS) {
+ error(hwnd, IDS_BAD_VALUE, valueName);
+ }
+ return lRet == ERROR_SUCCESS;
}
Index: programs/regedit/framewnd.c
===================================================================
RCS file: /var/cvs/wine/programs/regedit/framewnd.c,v
retrieving revision 1.5
diff -u -r1.5 framewnd.c
--- programs/regedit/framewnd.c 12 Dec 2003 04:08:59 -0000 1.5
+++ programs/regedit/framewnd.c 13 Dec 2003 06:57:03 -0000
@@ -441,12 +441,11 @@
BOOL result = TRUE;
LONG lRet;
- keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
- valueName = GetValueName(g_pChildWnd->hListWnd);
- if (keyPath) {
- lRet = RegOpenKeyEx(hKeyRoot, keyPath, 0, KEY_READ, &hKey);
+ if ((keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot))) {
+ lRet = RegOpenKeyEx(hKeyRoot, keyPath, 0, KEY_ALL_ACCESS, &hKey);
if (lRet != ERROR_SUCCESS) hKey = 0;
}
+ valueName = GetValueName(g_pChildWnd->hListWnd);
switch (LOWORD(wParam)) {
case ID_REGISTRY_IMPORTREGISTRYFILE:
@@ -461,6 +460,10 @@
break;
case ID_REGISTRY_PRINT:
PrintRegistryHive(hWnd, _T(""));
+ break;
+ case ID_EDIT_DELETE:
+ if (DeleteValue(hWnd, hKey, valueName))
+ RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
break;
case ID_EDIT_MODIFY:
if (ModifyValue(hWnd, hKey, valueName))
Index: programs/regedit/main.h
===================================================================
RCS file: /var/cvs/wine/programs/regedit/main.h,v
retrieving revision 1.8
diff -u -r1.8 main.h
--- programs/regedit/main.h 12 Dec 2003 04:08:59 -0000 1.8
+++ programs/regedit/main.h 12 Dec 2003 21:44:58 -0000
@@ -93,6 +93,7 @@
extern LPCTSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey);
/* edit.c */
-BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName);
+extern BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName);
+extern BOOL DeleteValue(HWND hwnd, HKEY hKey, LPCTSTR valueName);
#endif /* __MAIN_H__ */
Index: programs/regedit/resource.h
===================================================================
RCS file: /var/cvs/wine/programs/regedit/resource.h,v
retrieving revision 1.2
diff -u -r1.2 resource.h
--- programs/regedit/resource.h 3 Dec 2003 20:25:24 -0000 1.2
+++ programs/regedit/resource.h 13 Dec 2003 07:21:58 -0000
@@ -106,6 +106,12 @@
#define IDS_BAD_VALUE 32837
#define IDS_UNSUPPORTED_TYPE 32838
#define IDS_TOO_BIG_VALUE 32839
+#define IDS_DELETE_BOX_TITLE 32840
+#define IDS_DELETE_BOX_TEXT 32841
+#define IDD_EDIT_DWORD 32850
+#define IDC_DWORD_BASE 32852
+#define IDC_DWORD_HEX 32853
+#define IDC_DWORD_DEC 32854
#define IDD_EDIT_STRING 2000
#define IDC_VALUE_NAME 2001