Changes to regedit:
authorGregor Brunmar <gbrunmar.ros@gmail.com>
Sun, 30 Sep 2007 13:31:44 +0000 (13:31 +0000)
committerGregor Brunmar <gbrunmar.ros@gmail.com>
Sun, 30 Sep 2007 13:31:44 +0000 (13:31 +0000)
* Fixed updating tree view when renaming a key
* Fixed a tree view refresh bug
* Proper updating of the tree view when deleting keys

svn path=/trunk/; revision=29309

reactos/base/applications/regedit/childwnd.c
reactos/base/applications/regedit/framewnd.c
reactos/base/applications/regedit/treeview.c

index 3875c31..ce92f71 100644 (file)
@@ -522,7 +522,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
                   HKEY hRootKey;
                   HKEY hKey = NULL;
                   LPNMTVDISPINFO ptvdi;
-                  LONG lResult = ERROR_SUCCESS;
+                  LONG lResult = TRUE;
                   TCHAR szBuffer[MAX_PATH];
 
                   ptvdi = (LPNMTVDISPINFO) lParam;
@@ -533,13 +533,14 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
                     keyPath = GetItemPath(pChildWnd->hTreeWnd, ptvdi->item.hItem, &hRootKey);
                     if (RegOpenKeyEx(hRootKey, szBuffer, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
                     {
-                      lResult = REG_OPENED_EXISTING_KEY;
+                      lResult = FALSE;
                       RegCloseKey(hKey);
                       (void)TreeView_EditLabel(pChildWnd->hTreeWnd, ptvdi->item.hItem);
                     }
                     else
                     {
-                      lResult = RegRenameKey(hRootKey, keyPath, ptvdi->item.pszText);
+                      if (RegRenameKey(hRootKey, keyPath, ptvdi->item.pszText) != ERROR_SUCCESS)
+                                                 lResult = FALSE;
                     }
                     return lResult;
                   }
index 4f74693..a0ea7cb 100644 (file)
@@ -949,7 +949,10 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
              MessageBeep(MB_ICONHAND); 
           } else
           if (DeleteKey(hWnd, hKeyRoot, keyPath))
+          {
             DeleteNode(g_pChildWnd->hTreeWnd, 0);
+            RefreshTreeView(g_pChildWnd->hTreeWnd);
+          }
         }
        break;
     case ID_EDIT_NEW_STRINGVALUE:
index 884da97..8f56ca0 100644 (file)
@@ -218,7 +218,17 @@ BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
             pszNodes[dwActualSize] = '\0';
     }
 
-    /* Now go through all the children in the registry, and check if any have to be added. */
+    /* Now go through all the children in the tree, and check if any have to be removed. */
+    childItem = TreeView_GetChild(hwndTV, hItem);
+    while (childItem) {
+        HTREEITEM nextItem = TreeView_GetNextSibling(hwndTV, childItem);
+        if (RefreshTreeItem(hwndTV, childItem) == FALSE) {
+            (void)TreeView_DeleteItem(hwndTV, childItem);
+        }
+        childItem = nextItem;
+    }
+
+       /* Now go through all the children in the registry, and check if any have to be added. */
     bAddedAny = FALSE;
     for (dwIndex = 0; dwIndex < dwCount; dwIndex++) {
         DWORD cName = dwMaxSubKeyLen, dwSubCount;
@@ -258,15 +268,6 @@ BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
     if (bAddedAny)
         SendMessage(hwndTV, TVM_SORTCHILDREN, 0, (LPARAM) hItem);
 
-    /* Now go through all the children in the tree, and check if any have to be removed. */
-    childItem = TreeView_GetChild(hwndTV, hItem);
-    while (childItem) {
-        HTREEITEM nextItem = TreeView_GetNextSibling(hwndTV, childItem);
-        if (RefreshTreeItem(hwndTV, childItem) == FALSE) {
-            (void)TreeView_DeleteItem(hwndTV, childItem);
-        }
-        childItem = nextItem;
-    }
     bSuccess = TRUE;
 
 done: