From 1a98d2a214d8adafd5e792fd16fdfb636b0788c5 Mon Sep 17 00:00:00 2001 From: Gregor Brunmar Date: Sun, 30 Sep 2007 13:31:44 +0000 Subject: [PATCH] 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 svn path=/trunk/; revision=29309 --- reactos/base/applications/regedit/childwnd.c | 7 ++++--- reactos/base/applications/regedit/framewnd.c | 3 +++ reactos/base/applications/regedit/treeview.c | 21 ++++++++++---------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/reactos/base/applications/regedit/childwnd.c b/reactos/base/applications/regedit/childwnd.c index 3875c314bf3..ce92f710702 100644 --- a/reactos/base/applications/regedit/childwnd.c +++ b/reactos/base/applications/regedit/childwnd.c @@ -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; } diff --git a/reactos/base/applications/regedit/framewnd.c b/reactos/base/applications/regedit/framewnd.c index 4f746939a82..a0ea7cb0743 100644 --- a/reactos/base/applications/regedit/framewnd.c +++ b/reactos/base/applications/regedit/framewnd.c @@ -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: diff --git a/reactos/base/applications/regedit/treeview.c b/reactos/base/applications/regedit/treeview.c index 884da97077d..8f56ca0fa21 100644 --- a/reactos/base/applications/regedit/treeview.c +++ b/reactos/base/applications/regedit/treeview.c @@ -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: -- 2.17.1