fixed changing of string values (now it works)
authorThomas Bluemel <thomas@reactsoft.com>
Thu, 1 Jan 2004 17:29:05 +0000 (17:29 +0000)
committerThomas Bluemel <thomas@reactsoft.com>
Thu, 1 Jan 2004 17:29:05 +0000 (17:29 +0000)
svn path=/trunk/; revision=7392

reactos/subsys/system/regedit/edit.c
reactos/subsys/system/regedit/framewnd.c
reactos/subsys/system/regedit/listview.c

index 5c0107e..35fae09 100644 (file)
@@ -122,7 +122,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName)
     LONG lRet;
     BOOL result = FALSE;
 
-    if (!hKey || !valueName) return FALSE;
+    if (!hKey) return FALSE;
 
     editValueName = valueName;
 
@@ -159,7 +159,9 @@ BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName)
         }
         if (DialogBox(0, MAKEINTRESOURCE(IDD_EDIT_STRING), hwnd, modify_string_dlgproc) == IDOK) {
             if(stringValueData)
+            {MessageBox(0, stringValueData, valueName, 0);
               lRet = RegSetValueEx(hKey, valueName, 0, type, stringValueData, lstrlen(stringValueData) + 1);
+            }
             else
               lRet = RegSetValueEx(hKey, valueName, 0, type, NULL, 0);
             if (lRet == ERROR_SUCCESS) result = TRUE;
index 21865f9..9598248 100644 (file)
@@ -439,31 +439,50 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
     LPCTSTR keyPath;
     LPCTSTR valueName;
     BOOL result = TRUE;
+    REGSAM regsam = KEY_READ;
     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 (lRet != ERROR_SUCCESS) hKey = 0;
-    }
-
+    
     switch (LOWORD(wParam)) {
     case ID_REGISTRY_IMPORTREGISTRYFILE:
         ImportRegistryFile(hWnd);
-        break;
+        return TRUE;
     case ID_REGISTRY_EXPORTREGISTRYFILE:
         ExportRegistryFile(hWnd);
-        break;
+        return TRUE;
     case ID_REGISTRY_CONNECTNETWORKREGISTRY:
-        break;
+        return TRUE;
     case ID_REGISTRY_DISCONNECTNETWORKREGISTRY:
-        break;
+        return TRUE;
     case ID_REGISTRY_PRINT:
         PrintRegistryHive(hWnd, _T(""));
+        return TRUE;
+    case ID_REGISTRY_EXIT:
+        DestroyWindow(hWnd);
+        return TRUE;
+    case ID_VIEW_STATUSBAR:
+        toggle_child(hWnd, LOWORD(wParam), hStatusBar);
+        return TRUE;
+    case ID_HELP_HELPTOPICS:
+        WinHelp(hWnd, _T("regedit"), HELP_FINDER, 0);
+        return TRUE;
+    case ID_HELP_ABOUT:
+        ShowAboutBox(hWnd);
+        return TRUE;
+    case ID_EDIT_MODIFY:
+        regsam |= KEY_WRITE; 
         break;
+    }
+
+    keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
+    valueName = GetValueName(g_pChildWnd->hListWnd);
+    if (keyPath) {
+        lRet = RegOpenKeyEx(hKeyRoot, keyPath, 0, regsam, &hKey);
+        if (lRet != ERROR_SUCCESS) hKey = 0;
+    }
+
+     switch (LOWORD(wParam)) {
     case ID_EDIT_MODIFY:
-        if (ModifyValue(hWnd, hKey, valueName))
+        if (valueName && ModifyValue(hWnd, hKey, valueName))
             RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
         break;
     case ID_EDIT_COPYKEYNAME:
@@ -477,29 +496,19 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
         break;
     case ID_REGISTRY_OPENLOCAL:
         break;
-    case ID_REGISTRY_EXIT:
-        DestroyWindow(hWnd);
-        break;
+
     case ID_VIEW_REFRESH:
         RefreshView(hWnd);
         break;
    /*case ID_OPTIONS_TOOLBAR:*/
    /*  toggle_child(hWnd, LOWORD(wParam), hToolBar);*/
    /*    break;*/
-    case ID_VIEW_STATUSBAR:
-        toggle_child(hWnd, LOWORD(wParam), hStatusBar);
-        break;
-    case ID_HELP_HELPTOPICS:
-        WinHelp(hWnd, _T("regedit"), HELP_FINDER, 0);
-        break;
-    case ID_HELP_ABOUT:
-        ShowAboutBox(hWnd);
-        break;
     default:
         result = FALSE;
     }
-
-    RegCloseKey(hKey);
+    
+    if(hKey)
+      RegCloseKey(hKey);
     return result;
 }
 
index 8a50f7d..fc7c68a 100644 (file)
@@ -69,26 +69,31 @@ LPCTSTR GetValueName(HWND hwndLV)
     maxLen = HeapSize(GetProcessHeap(), 0, g_valueName);
     if (maxLen == (SIZE_T) - 1) return NULL;
 
-    item = ListView_GetNextItem(hwndLV, -1, LVNI_FOCUSED);
+    item = ListView_GetNextItem(hwndLV, -1, LVNI_FOCUSED | LVNI_SELECTED);
     if (item == -1) return NULL;
-    do {
-        LVItem.mask = LVIF_PARAM;
-        LVItem.iItem = item;
-        if(ListView_GetItem(hwndLV, &LVItem))
+    LVItem.mask = LVIF_PARAM;
+    LVItem.iItem = item;
+    for(;;)
+    {
+      if(ListView_GetItem(hwndLV, &LVItem))
+      {
+        lineinfo = (PLINE_INFO)LVItem.lParam;
+        if(!lineinfo->name)
         {
-          lineinfo = (PLINE_INFO)LVItem.lParam;
-          g_valueName = lineinfo->name;
-         len = _tcslen(g_valueName);
-         if (len < maxLen - 1) break;
-         newStr = HeapReAlloc(GetProcessHeap(), 0, g_valueName, maxLen * 2);
-         if (!newStr) return NULL;
-         g_valueName = newStr;
-         maxLen *= 2;
-       }
-       else
-         break;
-    } while (TRUE);
-
+          *g_valueName = 0;
+          return g_valueName;
+        }
+        len = _tcslen(lineinfo->name);
+        if (len < maxLen - 1) break;
+        newStr = HeapReAlloc(GetProcessHeap(), 0, g_valueName, maxLen * 2);
+        if (!newStr) return NULL;
+        g_valueName = newStr;
+        maxLen *= 2;
+      }
+      else
+        return NULL;
+    }
+    memcpy(g_valueName, lineinfo->name, sizeof(TCHAR) * (len + 1));
     return g_valueName;
 }