Jump to content
Developer Wiki and Function Reference Links ×

ExpandTreeControlItem How to Do in Script ?


Recommended Posts

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.

Link to comment

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);

Link to comment

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

Link to comment

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

Link to comment

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.

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...