cadtischler Posted January 17, 2013 Share Posted January 17, 2013 Hello, i want to expands or collapses an item in a tree control item by the Script. I can create, display and manage all of my tree control. But at the start, i want to 'close' all the Folders in the List, like shown in the Screenshot by the red oval. I try to do ExpandTreeControlItem(dialog1,4,0,FALSE); ExpandTreeControlItem(dialog1,4,7,TRUE); and similar, in many places of the script, but always the Folders are 'open', when i call RunLayoutDialog(...). What is my Mistake ? Best regards, Uwe. Quote Link to comment
maarten. Posted January 18, 2013 Share Posted January 18, 2013 Seems to work here (win 7, vw2013). By running the script below as resource script, i get a dialog where "root1" is expanded and "root2" is collapsed. PROCEDURE Example; VAR dialog1 :INTEGER; result :INTEGER; widthInChars, heightInChars :INTEGER; root1, root2, child1, child2 :INTEGER; PROCEDURE Dialog_Handler(VAR item :LONGINT; data :LONGINT); BEGIN CASE item OF SetupDialogC: BEGIN root1 := InsertTreeControlItem(dialog1, 4, 'root1', -1, 0); child1 := InsertTreeControlItem(dialog1, 4, 'child1', root1, 0); child2 := InsertTreeControlItem(dialog1, 4, 'child2', root1, child1); root2 := InsertTreeControlItem(dialog1, 4, 'root2', -1, root1); child1 := InsertTreeControlItem(dialog1, 4, 'child1', root2, 0); child2 := InsertTreeControlItem(dialog1, 4, 'child2', root2, child1); ExpandTreeControlItem(dialog1,4,0,TRUE); END; END; END; BEGIN dialog1 := CreateLayout('Example Dialog', FALSE, 'OK', 'Cancel'); widthInChars := 28; heightInChars := 8; CreateTreeControl(dialog1, 4, widthInChars, heightInChars); SetFirstLayoutItem(dialog1, 4); result := RunLayoutDialog(dialog1, Dialog_Handler); END; RUN(Example); Quote Link to comment
MullinRJ Posted January 18, 2013 Share Posted January 18, 2013 Maarten, ???When I run your script, both ROOT1 and ROOT2 are expanded. Changing TRUE to FALSE in ExpandTreeControlItem(dialog1, 4, 0, FALSE); collapses ROOT1. To collapse ROOT2 another line would be needed. ExpandTreeControlItem(dialog1, 4, root2, TRUE); ???In this example, root2 = 3, as it is the fourth item in the list and the list starts counting at 0. Uwe, ???In your example, assuming you used "4" as the dialog item number for your tree in: CreateTreeControl(dialog1, 4, widthInChars, heightInChars); try: ExpandTreeControlItem(dialog1, 4, 7, FALSE); HTH, Raymond Quote Link to comment
MullinRJ Posted January 18, 2013 Share Posted January 18, 2013 Uwe, ???You may have a problem. I posted my results using Maarten's script and VW 2013 and it works. I tried the same script in VW 2012 back to VW 2009 and it does not work in any of them. I think this is a bug that was fixed in the latest version and there may not be a workaround in earlier versions. Apologies for any false hope. Raymond Quote Link to comment
Miguel Barrera Posted January 18, 2013 Share Posted January 18, 2013 Thanks Raymond for the research. I had a resource dialog picker with the tree control since it was introduced but could not implement it in my plug-ins because the expand, collapse, and select functions were not working. I am hoping the select function is working now also. Quote Link to comment
cadtischler Posted January 18, 2013 Author Share Posted January 18, 2013 Hello, thanks for this great and fast answers. @Maarten: You are right. In VW2013 it will work fine, also on a Mac. @Raymond: After your posting, i tested it in 2013. The SelectTreeControlItem(...) works too. On Mac there is also a new Design of TreeControl-Items, so it is really possible, that there will be an old bug in 2012. So there is no big problem. In the next days i will change my Worksspace to VW 2013. And the Procedure SetTreeControlItemData() and GetTreeControlItemData() works also fine now in 2013. I dont know, for what to use, but they works. @All Please exuse me for my broken english. Thank you all very much, Uwe. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.