Author: gbrunmar
Date: Sun Sep 30 17:31:44 2007
New Revision: 29309
URL: 
http://svn.reactos.org/svn/reactos?rev=29309&view=rev
Log:
Changes to regedit:
* Fixed updating tree view when renaming a key
* Fixed a tree view refresh bug
* Proper updating of the tree view when deleting keys
Modified:
    trunk/reactos/base/applications/regedit/childwnd.c
    trunk/reactos/base/applications/regedit/framewnd.c
    trunk/reactos/base/applications/regedit/treeview.c
Modified: trunk/reactos/base/applications/regedit/childwnd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/regedit/…
==============================================================================
--- trunk/reactos/base/applications/regedit/childwnd.c (original)
+++ trunk/reactos/base/applications/regedit/childwnd.c Sun Sep 30 17:31:44 2007
@@ -522,7 +522,7 @@
                   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 @@
                     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;
                   }
Modified: trunk/reactos/base/applications/regedit/framewnd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/regedit/…
==============================================================================
--- trunk/reactos/base/applications/regedit/framewnd.c (original)
+++ trunk/reactos/base/applications/regedit/framewnd.c Sun Sep 30 17:31:44 2007
@@ -949,7 +949,10 @@
              MessageBeep(MB_ICONHAND);
           } else
           if (DeleteKey(hWnd, hKeyRoot, keyPath))
+          {
             DeleteNode(g_pChildWnd->hTreeWnd, 0);
+            RefreshTreeView(g_pChildWnd->hTreeWnd);
+          }
         }
        break;
     case ID_EDIT_NEW_STRINGVALUE:
Modified: trunk/reactos/base/applications/regedit/treeview.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/regedit/…
==============================================================================
--- trunk/reactos/base/applications/regedit/treeview.c (original)
+++ trunk/reactos/base/applications/regedit/treeview.c Sun Sep 30 17:31:44 2007
@@ -218,7 +218,17 @@
             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 @@
     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: