1. Fixed a bug that caused registry keys created under previously
childless keys to not show up in the tree view
2. If a registry key deletion fails because of a permission error part
of the way through, the key will be refeshed and the partial deletion
will show up
Modified: trunk/reactos/subsys/system/regedit/childwnd.c
Modified: trunk/reactos/subsys/system/regedit/main.h
Modified: trunk/reactos/subsys/system/regedit/treeview.c
_____
Modified: trunk/reactos/subsys/system/regedit/childwnd.c
--- trunk/reactos/subsys/system/regedit/childwnd.c 2005-11-22
01:06:05 UTC (rev 19442)
+++ trunk/reactos/subsys/system/regedit/childwnd.c 2005-11-22
01:30:30 UTC (rev 19443)
@@ -141,6 +141,8 @@
{
if (RegDeleteKeyRecursive(hRootKey, keyPath) ==
ERROR_SUCCESS)
TreeView_DeleteItem(pChildWnd->hTreeWnd, hSelection);
+ else
+ RefreshTreeItem(pChildWnd->hTreeWnd, hSelection); /* If
delete failed; refresh to see partial results */
}
break;
case ID_EDIT_COPYKEYNAME:
_____
Modified: trunk/reactos/subsys/system/regedit/main.h
--- trunk/reactos/subsys/system/regedit/main.h 2005-11-22 01:06:05 UTC
(rev 19442)
+++ trunk/reactos/subsys/system/regedit/main.h 2005-11-22 01:30:30 UTC
(rev 19443)
@@ -101,6 +101,7 @@
/* treeview.c */
extern HWND CreateTreeView(HWND hwndParent, LPTSTR pHostName, int id);
extern BOOL RefreshTreeView(HWND hWndTV);
+extern BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem);
extern BOOL OnTreeExpanding(HWND hWnd, NMTREEVIEW* pnmtv);
extern LPCTSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY*
phRootKey);
extern HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPTSTR name);
_____
Modified: trunk/reactos/subsys/system/regedit/treeview.c
--- trunk/reactos/subsys/system/regedit/treeview.c 2005-11-22
01:06:05 UTC (rev 19442)
+++ trunk/reactos/subsys/system/regedit/treeview.c 2005-11-22
01:30:30 UTC (rev 19443)
@@ -132,7 +132,7 @@
return TreeView_InsertItem(hwndTV, &tvins);
}
-static BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
+BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
{
HKEY hRoot, hKey, hSubKey;
HTREEITEM childItem;
@@ -312,28 +312,46 @@
HTREEITEM hNewItem = 0;
TVITEMEX item;
- if (!hItem) hItem = TreeView_GetSelection(hwndTV);
- if (!hItem) return FALSE;
- if (TreeView_GetItemState(hwndTV, hItem, TVIS_EXPANDEDONCE)) {
- hNewItem = AddEntryToTree(hwndTV, hItem, name, 0, 0);
- SendMessage(hwndTV, TVM_SORTCHILDREN, 0, (LPARAM) hItem);
- } else {
- item.mask = TVIF_CHILDREN | TVIF_HANDLE;
- item.hItem = hItem;
- if (!TreeView_GetItem(hwndTV, &item)) return FALSE;
- item.cChildren = 1;
- if (!TreeView_SetItem(hwndTV, &item)) return FALSE;
+ /* Default to the current selection */
+ if (!hItem)
+ {
+ hItem = TreeView_GetSelection(hwndTV);
+ if (!hItem)
+ return FALSE;
}
+
+ memset(&item, 0, sizeof(item));
+ item.hItem = hItem;
+ item.mask = TVIF_CHILDREN | TVIF_HANDLE | TVIF_STATE;
+ if (!TreeView_GetItem(hwndTV, &item))
+ return FALSE;
+
+ if ((item.state & TVIS_EXPANDEDONCE) && (item.cChildren > 0))
+ {
+ hNewItem = AddEntryToTree(hwndTV, hItem, name, 0, 0);
+ SendMessage(hwndTV, TVM_SORTCHILDREN, 0, (LPARAM) hItem);
+ }
+ else
+ {
+ item.mask = TVIF_CHILDREN | TVIF_HANDLE;
+ item.hItem = hItem;
+ item.cChildren = 1;
+ if (!TreeView_SetItem(hwndTV, &item))
+ return FALSE;
+ }
+
TreeView_Expand(hwndTV, hItem, TVE_EXPAND);
- if (!hNewItem) {
- for(hNewItem = TreeView_GetChild(hwndTV, hItem); hNewItem;
hNewItem = TreeView_GetNextSibling(hwndTV, hNewItem)) {
- item.mask = TVIF_HANDLE | TVIF_TEXT;
- item.hItem = hNewItem;
- item.pszText = buf;
- item.cchTextMax = COUNT_OF(buf);
- if (!TreeView_GetItem(hwndTV, &item)) continue;
- if (lstrcmp(name, item.pszText) == 0) break;
- }
+ if (!hNewItem)
+ {
+ for(hNewItem = TreeView_GetChild(hwndTV, hItem); hNewItem;
hNewItem = TreeView_GetNextSibling(hwndTV, hNewItem))
+ {
+ item.mask = TVIF_HANDLE | TVIF_TEXT;
+ item.hItem = hNewItem;
+ item.pszText = buf;
+ item.cchTextMax = COUNT_OF(buf);
+ if (!TreeView_GetItem(hwndTV, &item)) continue;
+ if (lstrcmp(name, item.pszText) == 0) break;
+ }
}
if (hNewItem) TreeView_SelectItem(hwndTV, hNewItem);
@@ -510,6 +528,7 @@
if (LoadString(hInst, IDS_NEW_KEY, szNewKeyFormat,
sizeof(szNewKeyFormat) / sizeof(szNewKeyFormat[0])) <= 0)
goto done;
+ /* Need to create a new key with a unique name */
do
{
_sntprintf(szNewKey, sizeof(szNewKey) / sizeof(szNewKey[0]),
szNewKeyFormat, iIndex++);
@@ -522,10 +541,12 @@
}
while(!hNewKey);
- hNewItem = AddEntryToTree(hwndTV, hItem, szNewKey, NULL, 0);
+ /* Insert the new key */
+ hNewItem = InsertNode(hwndTV, hItem, szNewKey);
if (!hNewItem)
goto done;
- SendMessage(hwndTV, TVM_SORTCHILDREN, 0, (LPARAM) hItem);
+
+ /* The new key's name is probably not appropriate yet */
TreeView_EditLabel(hwndTV, hNewItem);
bSuccess = TRUE;