David Aynardi Posted December 16, 2004 Share Posted December 16, 2004 Ok, whats up with this? I make a list box and populate it with a fixed number of elements. When I click on one of the items in the box to make a selection, everything in the box (actually in all boxes) is duplicated. The box keeps growing every time I make a selection. What is happening? How do I prevent it? And where can I find some examples of basic user interface stuff so I don't need to keep asking dumb questions? {/////////////////////////////////////////////////////////////// Listbox Test By: DAynardi Built with Dialog Builder 4 © 2001 Nemetschek North America. ///////////////////////////////////////////////////////////////} PROCEDURE Listboxt; VAR ln,dlogID,dlogResult, Nlayer : INTEGER; dialogIsOK,rsrcOK : BOOLEAN; Lh : Handle; Layer : STRING; Layerlist: DYNARRAY[]OF STRING; { dialog related subroutines } {Load the list box} PROCEDURE Layerload; BEGIN Ln:=1; Lh:=LLayer; Nlayer:=NumLayers; ALLOCATE Layerlist[1..Nlayer]; REPEAT Layer:=GetLName(Lh); Layerlist[Ln]:=Layer; Lh:=prevlayer(Lh); INSERTCHOICE (4,0,Layer); Ln:=Ln+1; UNTIL (Lh=NIL); END; { Dialog definition function subroutine } FUNCTION Define_ListboxTest : INTEGER; VAR dialogID : INTEGER; BEGIN dialogID := CreateLayout('Untitled Dialog',True,'OK','Cancel'); CreateListBox(dialogID,4,25,25); SetFirstLayoutItem(dialogID,4); SetHelpString(1,'Accepts dialog data.'); SetHelpString(2,'Cancels operation without changes.'); SetHelpString(4,'A list box control.'); Define_ListboxTest := dialogID; END; { Dialog driver function subroutine } PROCEDURE Drive_ListboxTest(VAR item:LONGINT; data:LONGINT); BEGIN Layerload; CASE item OF SetupDialogC:BEGIN END; { user selected OK button } 1:BEGIN END; { user selected Cancel button } 2:BEGIN END; 4:BEGIN END; END; END; { main body of script } BEGIN dlogID := Define_ListboxTest; dialogIsOK := VerifyLayout(dlogID); IF dialogIsOK THEN BEGIN dlogResult := RunLayoutDialog(dlogID,Drive_ListboxTest); END; END; Run(ListboxT); Quote Link to comment
Vectorworks, Inc Employee klinzey Posted December 16, 2004 Vectorworks, Inc Employee Share Posted December 16, 2004 You need to move the Layerload call inside the case of SetupDialogC. Modern dialogs work by calling Drive_ListboxTest everytime there is a dialog event, so you are calling Layerload with every click. 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.