[REGEDIT]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Mon, 17 Dec 2012 23:22:03 +0000 (23:22 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Mon, 17 Dec 2012 23:22:03 +0000 (23:22 +0000)
Update the address bar after creating a registry key.
CORE-6816 #resolve #comment Committed in r57940. Thanks ;)

svn path=/trunk/; revision=57940

reactos/base/applications/regedit/childwnd.c

index 168861a..0492f74 100644 (file)
@@ -35,7 +35,7 @@ extern LPCWSTR get_root_key_name(HKEY hRootKey)
     if (hRootKey == HKEY_CURRENT_CONFIG) return L"HKEY_CURRENT_CONFIG";
     if (hRootKey == HKEY_DYN_DATA) return L"HKEY_DYN_DATA";
 
-    return L"UKNOWN HKEY, PLEASE REPORT";
+    return L"UNKNOWN HKEY, PLEASE REPORT";
 }
 
 extern void ResizeWnd(int cx, int cy)
@@ -303,6 +303,53 @@ LRESULT CALLBACK AddressBarProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar
     return CallWindowProc(oldwndproc, hwnd, uMsg, wParam, lParam);
 }
 
+static VOID
+UpdateAddress(HTREEITEM hItem, HKEY hRootKey, LPCWSTR pszPath)
+{
+    LPCWSTR keyPath, rootName;
+    LPWSTR fullPath;
+
+    if (pszPath == NULL)
+        keyPath = GetItemPath(g_pChildWnd->hTreeWnd, hItem, &hRootKey);
+    else
+        keyPath = pszPath;
+
+    if (keyPath)
+    {
+        RefreshListView(g_pChildWnd->hListWnd, hRootKey, keyPath);
+        rootName = get_root_key_name(hRootKey);
+        fullPath = HeapAlloc(GetProcessHeap(), 0, (wcslen(rootName) + 1 + wcslen(keyPath) + 1) * sizeof(WCHAR));
+        if (fullPath)
+        {
+            /* set (correct) the address bar text */
+            if (keyPath[0] != L'\0')
+                swprintf(fullPath, L"%s\\%s", rootName, keyPath);
+            else
+                fullPath = wcscpy(fullPath, rootName);
+            SendMessageW(hStatusBar, SB_SETTEXTW, 0, (LPARAM)fullPath);
+            SendMessageW(g_pChildWnd->hAddressBarWnd, WM_SETTEXT, 0, (LPARAM)fullPath);
+            HeapFree(GetProcessHeap(), 0, fullPath);
+            /* disable hive manipulation items temporarily (enable only if necessary) */
+            EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_LOADHIVE, MF_BYCOMMAND | MF_GRAYED);
+            EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_UNLOADHIVE, MF_BYCOMMAND | MF_GRAYED);
+            /* compare the strings to see if we should enable/disable the "Load Hive" menus accordingly */
+            if (!(wcsicmp(rootName, L"HKEY_LOCAL_MACHINE") &&
+                  wcsicmp(rootName, L"HKEY_USERS")))
+            {
+                /*
+                 * enable the unload menu item if at the root, otherwise
+                 * enable the load menu item if there is no slash in
+                 * keyPath (ie. immediate child selected)
+                 */
+                if(keyPath[0] == L'\0')
+                    EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_LOADHIVE, MF_BYCOMMAND | MF_ENABLED);
+                else if(!wcschr(keyPath, L'\\'))
+                    EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_UNLOADHIVE, MF_BYCOMMAND | MF_ENABLED);
+            }
+        }
+    }
+}
+
 /*******************************************************************************
  *
  *  FUNCTION: ChildWndProc(HWND, unsigned, WORD, LONG)
@@ -494,45 +541,8 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
             case TVN_ITEMEXPANDING:
                 return !OnTreeExpanding(g_pChildWnd->hTreeWnd, (NMTREEVIEW*)lParam);
             case TVN_SELCHANGED:
-            {
-                LPCWSTR keyPath, rootName;
-                LPWSTR fullPath;
-                HKEY hRootKey;
-
-                keyPath = GetItemPath(g_pChildWnd->hTreeWnd, ((NMTREEVIEW*)lParam)->itemNew.hItem, &hRootKey);
-                if (keyPath)
-                {
-                    RefreshListView(g_pChildWnd->hListWnd, hRootKey, keyPath);
-                    rootName = get_root_key_name(hRootKey);
-                    fullPath = HeapAlloc(GetProcessHeap(), 0, (wcslen(rootName) + 1 + wcslen(keyPath) + 1) * sizeof(WCHAR));
-                    if (fullPath)
-                    {
-                        /* set (correct) the address bar text */
-                        if(keyPath[0] != L'\0')
-                            swprintf(fullPath, L"%s\\%s", rootName, keyPath);
-                        else
-                            fullPath = wcscpy(fullPath, rootName);
-                        SendMessageW(hStatusBar, SB_SETTEXTW, 0, (LPARAM)fullPath);
-                        SendMessageW(g_pChildWnd->hAddressBarWnd, WM_SETTEXT, 0, (LPARAM)fullPath);
-                        HeapFree(GetProcessHeap(), 0, fullPath);
-                        /* disable hive manipulation items temporarily (enable only if necessary) */
-                        EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_LOADHIVE, MF_BYCOMMAND | MF_GRAYED);
-                        EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_UNLOADHIVE, MF_BYCOMMAND | MF_GRAYED);
-                        /* compare the strings to see if we should enable/disable the "Load Hive" menus accordingly */
-                        if (!(wcsicmp(rootName, L"HKEY_LOCAL_MACHINE") &&
-                                wcsicmp(rootName, L"HKEY_USERS")))
-                        {
-                            // enable the unload menu item if at the root
-                            // otherwise enable the load menu item if there is no slash in keyPath (ie. immediate child selected)
-                            if(keyPath[0] == L'\0')
-                                EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_LOADHIVE, MF_BYCOMMAND | MF_ENABLED);
-                            else if(!wcschr(keyPath, L'\\'))
-                                EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_UNLOADHIVE, MF_BYCOMMAND | MF_ENABLED);
-                        }
-                    }
-                }
-            }
-            break;
+                UpdateAddress(((NMTREEVIEW*)lParam)->itemNew.hItem, NULL, NULL);
+                break;
             case NM_SETFOCUS:
                 g_pChildWnd->nFocusPanel = 0;
                 break;
@@ -571,6 +581,8 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
                     {
                         if (RenameKey(hRootKey, keyPath, ptvdi->item.pszText) != ERROR_SUCCESS)
                             lResult = FALSE;
+                        else
+                            UpdateAddress(ptvdi->item.hItem, hRootKey, szBuffer);
                     }
                     return lResult;
                 }