Regedit: Optimized tree expansion Modified: trunk/reactos/subsys/system/regedit/treeview.c _____
Modified: trunk/reactos/subsys/system/regedit/treeview.c --- trunk/reactos/subsys/system/regedit/treeview.c 2005-09-28 23:52:24 UTC (rev 18144) +++ trunk/reactos/subsys/system/regedit/treeview.c 2005-09-29 00:50:40 UTC (rev 18145) @@ -123,7 +123,7 @@
tvi.cChildren = dwChildren; tvi.lParam = (LPARAM)hKey; tvins.u.item = tvi; - tvins.hInsertAfter = (HTREEITEM)(hKey ? TVI_LAST : TVI_SORT); + tvins.hInsertAfter = (HTREEITEM)(hKey ? TVI_LAST : TVI_FIRST); tvins.hParent = hParent; return TreeView_InsertItem(hwndTV, &tvins); } @@ -139,6 +139,7 @@ LPTSTR pszNodes = NULL; BOOL bSuccess = FALSE; LPTSTR s; + BOOL bAddedAny;
KeyPath = GetItemPath(hwndTV, hItem, &hRoot);
@@ -219,6 +220,7 @@ }
/* 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; BOOL found; @@ -249,10 +251,14 @@ }
AddEntryToTree(hwndTV, hItem, Name, NULL, dwSubCount); + bAddedAny = TRUE; } } RegCloseKey(hKey);
+ 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) { @@ -306,6 +312,7 @@ 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; @@ -514,6 +521,7 @@ hNewItem = AddEntryToTree(hwndTV, hItem, szNewKey, NULL, 0); if (!hNewItem) goto done; + SendMessage(hwndTV, TVM_SORTCHILDREN, 0, (LPARAM) hItem); TreeView_EditLabel(hwndTV, hNewItem);
bSuccess = TRUE;