On Friday, 17 February 2017 9:42 AM, Nikolay Sivov wrote:
--- a/programs/regedit/treeview.c +++ b/programs/regedit/treeview.c @@ -477,12 +477,12 @@ BOOL RefreshTreeView(HWND hwndTV) hItem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hRoot); while (hItem) { RefreshTreeItem(hwndTV, hItem); + SendMessageW(hwndTV, TVM_SORTCHILDREN, TRUE, (LPARAM)hItem); hItem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)hItem); } SendMessageW(hwndTV, WM_SETREDRAW, TRUE, 0); InvalidateRect(hwndTV, NULL, FALSE); - SendMessageW(hwndTV, TVM_SORTCHILDREN, TRUE, (LPARAM)hSelectedItem); SetCursor(hcursorOld);
This doesn't seem to work. None of the treeview nodes are sorted when you click Refresh or press F5, but immediate children were sorted before this patch. Can you please take another look?
This is probably due to an incomplete TREEVIEW_SortChildren() function in comctl32.
case TVM_SORTCHILDREN: return TREEVIEW_SortChildren(infoPtr, lParam);
Note that we ignore the wParam, which MSDN says is a "Value that specifies whether the sorting is recursive. Set wParam to TRUE to sort all levels of child items below the parent item. Otherwise, only the parent's immediate children are sorted. "
-- Hugh McMaster
On 17.02.2017 15:19, Hugh McMaster wrote:
On Friday, 17 February 2017 9:42 AM, Nikolay Sivov wrote:
--- a/programs/regedit/treeview.c +++ b/programs/regedit/treeview.c @@ -477,12 +477,12 @@ BOOL RefreshTreeView(HWND hwndTV) hItem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hRoot); while (hItem) { RefreshTreeItem(hwndTV, hItem);
SendMessageW(hwndTV, TVM_SORTCHILDREN, TRUE, (LPARAM)hItem); hItem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)hItem);
}
SendMessageW(hwndTV, WM_SETREDRAW, TRUE, 0); InvalidateRect(hwndTV, NULL, FALSE);
- SendMessageW(hwndTV, TVM_SORTCHILDREN, TRUE, (LPARAM)hSelectedItem); SetCursor(hcursorOld);
This doesn't seem to work. None of the treeview nodes are sorted when you click Refresh or press F5, but immediate children were sorted before this patch. Can you please take another look?
It works in a way that immediate children of HKEY_* nodes are sorted now regardless of current selection. And order of HKEY_* nodes is fixed. But yes, this is only a part of what we want, it also has to recurse.
This is probably due to an incomplete TREEVIEW_SortChildren() function in comctl32.
case TVM_SORTCHILDREN: return TREEVIEW_SortChildren(infoPtr, lParam);
Note that we ignore the wParam, which MSDN says is a "Value that specifies whether the sorting is recursive. Set wParam to TRUE to sort all levels of child items below the parent item. Otherwise, only the parent's immediate children are sorted. "
This is correct, wParam does nothing for this message. You can also confirm that using native comctl32.
Please ignore this patch, it fixes one thing without fixing important part.
-- Hugh McMaster