crash748 Posted April 23, 2008 Share Posted April 23, 2008 (edited) I don't know why but the _GUICtrlTreeViewSort() function doesn't do the job. In Section1: SubSection1 content is sort. SubSection2 content is not sort. SubSection3 content is not sort. In Section2: SubSection1 content is not sort. SubSection2 content is not sort. SubSection3 content is not sort. How can i do to make all subsection sorted? Example of the problem:expandcollapse popup[/b][b][[/b][b]/b][b]#include[/b][b] <GUIConstants.au3> #include <GuiTreeView.au3> Global $Title = "Part of my script" Opt("GUIOnEventMode", 1) $GUI1 = GUICreate($Title, 300, 410) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE_GUI1") $treeview = GUICtrlCreateTreeView(10, 10, 280, 370, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_SINGLEEXPAND), $WS_EX_CLIENTEDGE) ;* $Section1 = GUICtrlCreateTreeViewItem("1 - Section", $treeview) GUICtrlSetColor(-1, 0x0000C0) $Section2 = GUICtrlCreateTreeViewItem("2 - Section", $treeview) GUICtrlSetColor(-1, 0x0000C0) ;** $SubSection3_1 = GUICtrlCreateTreeViewItem("SubSection3", $Section1) GUICtrlSetColor(-1, 0x0000C0) $SubSection2_1 = GUICtrlCreateTreeViewItem("SubSection2", $Section1) GUICtrlSetColor(-1, 0x0000C0) $SubSection1_1 = GUICtrlCreateTreeViewItem("SubSection1", $Section1) GUICtrlSetColor(-1, 0x0000C0) $SubSection3_2 = GUICtrlCreateTreeViewItem("SubSection3", $Section2) GUICtrlSetColor(-1, 0x0000C0) $SubSection2_2 = GUICtrlCreateTreeViewItem("SubSection2", $Section2) GUICtrlSetColor(-1, 0x0000C0) $SubSection1_2 = GUICtrlCreateTreeViewItem("SubSection1", $Section2) GUICtrlSetColor(-1, 0x0000C0) ;*** $ItemD = GUICtrlCreateTreeViewItem("ItemD", $SubSection1_1) $ItemA = GUICtrlCreateTreeViewItem("ItemA", $SubSection1_1) $ItemF = GUICtrlCreateTreeViewItem("ItemF", $SubSection1_1) $ItemZ = GUICtrlCreateTreeViewItem("ItemZ", $SubSection1_1) $ItemM = GUICtrlCreateTreeViewItem("ItemM", $SubSection1_1) $ItemL = GUICtrlCreateTreeViewItem("ItemL", $SubSection1_1) $ItemB = GUICtrlCreateTreeViewItem("ItemB", $SubSection1_1) $ItemC = GUICtrlCreateTreeViewItem("ItemC", $SubSection1_1) $ItemD2 = GUICtrlCreateTreeViewItem("ItemD", $SubSection2_1) $ItemA2 = GUICtrlCreateTreeViewItem("ItemA", $SubSection2_1) $ItemF2 = GUICtrlCreateTreeViewItem("ItemF", $SubSection2_1) $ItemZ2 = GUICtrlCreateTreeViewItem("ItemZ", $SubSection2_1) $ItemM2 = GUICtrlCreateTreeViewItem("ItemM", $SubSection2_1) $ItemL2 = GUICtrlCreateTreeViewItem("ItemL", $SubSection2_1) $ItemB2 = GUICtrlCreateTreeViewItem("ItemB", $SubSection2_1) $ItemC2 = GUICtrlCreateTreeViewItem("ItemC", $SubSection2_1) $ItemD3 = GUICtrlCreateTreeViewItem("ItemD", $SubSection3_1) $ItemA3 = GUICtrlCreateTreeViewItem("ItemA", $SubSection3_1) $ItemF3 = GUICtrlCreateTreeViewItem("ItemF", $SubSection3_1) $ItemZ3 = GUICtrlCreateTreeViewItem("ItemZ", $SubSection3_1) $ItemM3 = GUICtrlCreateTreeViewItem("ItemM", $SubSection3_1) $ItemL3 = GUICtrlCreateTreeViewItem("ItemL", $SubSection3_1) $ItemB3 = GUICtrlCreateTreeViewItem("ItemB", $SubSection3_1) $ItemC3 = GUICtrlCreateTreeViewItem("ItemC", $SubSection3_1) $SelD = GUICtrlCreateTreeViewItem("SelD", $SubSection1_2) $SelA = GUICtrlCreateTreeViewItem("SelA", $SubSection1_2) $SelF = GUICtrlCreateTreeViewItem("SelF", $SubSection1_2) $SelZ = GUICtrlCreateTreeViewItem("SelZ", $SubSection1_2) $SelM = GUICtrlCreateTreeViewItem("SelM", $SubSection1_2) $SelL = GUICtrlCreateTreeViewItem("SelL", $SubSection1_2) $SelB = GUICtrlCreateTreeViewItem("SelB", $SubSection1_2) $SelC = GUICtrlCreateTreeViewItem("SelC", $SubSection1_2) $SelD2 = GUICtrlCreateTreeViewItem("SelD", $SubSection2_2) $SelA2 = GUICtrlCreateTreeViewItem("SelA", $SubSection2_2) $SelF2 = GUICtrlCreateTreeViewItem("SelF", $SubSection2_2) $SelZ2 = GUICtrlCreateTreeViewItem("SelZ", $SubSection2_2) $SelM2 = GUICtrlCreateTreeViewItem("SelM", $SubSection2_2) $SelL2 = GUICtrlCreateTreeViewItem("SelL", $SubSection2_2) $SelB2 = GUICtrlCreateTreeViewItem("SelB", $SubSection2_2) $SelC2 = GUICtrlCreateTreeViewItem("SelC", $SubSection2_2) $SelD3 = GUICtrlCreateTreeViewItem("SelD", $SubSection3_2) $SelA3 = GUICtrlCreateTreeViewItem("SelA", $SubSection3_2) $SelF3 = GUICtrlCreateTreeViewItem("SelF", $SubSection3_2) $SelZ3 = GUICtrlCreateTreeViewItem("SelZ", $SubSection3_2) $SelM3 = GUICtrlCreateTreeViewItem("SelM", $SubSection3_2) $SelL3 = GUICtrlCreateTreeViewItem("SelL", $SubSection3_2) $SelB3 = GUICtrlCreateTreeViewItem("SelB", $SubSection3_2) $SelC3 = GUICtrlCreateTreeViewItem("SelC", $SubSection3_2) ;sort $SortButton = GUICtrlCreateButton("Sort", 100, 385, 100, 20) GUICtrlSetOnEvent(-1, "Sort") GUISetState() ControlFocus($GUI1, "", $treeview) While 1 Sleep(250) WEnd Func Sort() _GUICtrlTreeViewSort($treeview) EndFunc ;==>Sort Func CLOSE_GUI1() Exit EndFunc ;==>CLOSE_GUI1[/b] Edited April 24, 2008 by crash748 Link to comment Share on other sites More sharing options...
crash748 Posted April 23, 2008 Author Share Posted April 23, 2008 Bump! Anybody has an idea? Link to comment Share on other sites More sharing options...
Siao Posted April 24, 2008 Share Posted April 24, 2008 (edited) Not sure why TVM_SORTCHILDREN doesn't work as documented on MSDN (i.e. "sort all levels of child items below the parent item"), and not sure why _GUICtrlTreeView_Sort is coded the way it currently is, (and looks like your AutoIt needs updating if you're using _GUICtrlTreeViewSort), but you can try this instead: Func __GUICtrlTreeView_Sort($hWnd) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) Local $hItem, $i_Recursive = 1 $hItem = _GUICtrlTreeView_GetFirstItem($hWnd) While $hItem <> 0 DllCall('user32.dll','int','SendMessage', 'hwnd',$hWnd, 'uint',$TVM_SORTCHILDREN, 'wparam',$i_Recursive, 'lparam',$hItem) $hItem = _GUICtrlTreeView_GetNext($hWnd, $hItem) WEnd EndFunc Edited April 24, 2008 by Siao "be smart, drink your wine" Link to comment Share on other sites More sharing options...
crash748 Posted April 24, 2008 Author Share Posted April 24, 2008 (edited) Thank you very much! Everything is sort corectly!! Edited April 24, 2008 by crash748 Link to comment Share on other sites More sharing options...
lewisg Posted August 16, 2012 Share Posted August 16, 2012 I know this is an old topic however this fix "saved my bacon", thanks, thanks, thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now