Index: base/applications/regedit/childwnd.c =================================================================== --- base/applications/regedit/childwnd.c (revision 57871) +++ base/applications/regedit/childwnd.c (working copy) @@ -303,6 +303,49 @@ 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 +537,8 @@ 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 +577,8 @@ { if (RenameKey(hRootKey, keyPath, ptvdi->item.pszText) != ERROR_SUCCESS) lResult = FALSE; + else + UpdateAddress(ptvdi->item.hItem, hRootKey, szBuffer); } return lResult; }