Jump to content
Developer Wiki and Function Reference Links ×

Dialog with n-number of items

Recommended Posts



I'm trying to display a legend, but I would like to be able to select the specific hatches to be displayed.

Since I don't know how many hatches are used in a drawing, would it be possible to build a dialog according to the - schematic - code below? 

HatchId := BuildResourceList (66, 14, 'Hulpbronnen - Lijnarceringen', HatchNum);

      FOR n := 1 TO HatchNum DO
          CreateCheckBox (DialogId, Item(n), Index2Name(Item(n)));

          SetFirstLayoutItem (DialogId, Item(n));
          SetBelowItem (DialogId, Item(n), Item(n) + 1, 0, 0);



Link to comment

It's conceivable but would be messy, and could also be problematic if there were so many hatches that the dialogue was too large to fit on the screen. Normally you would would use a list browser for something like this, which would see scroll bars appear if the list was longer than the size of the list browser.

Link to comment

We usualy get by with about 6 relevant hatches, so it seems doable to me, especially if we would restrict the number of hatches in the dialog to about twelve items [1..12].

Wouldn't be bad for the drawing hygiene as well...


What would be the easiest way to differentiate between the different hatches.

I guess I would have to script something like the code mentioned above, but I noticed it is will not be as easy as that.


Any basic suggestions about how to aproach this dialog? or how to approach a dialog with n-number of items? 

Link to comment
  • Vectorworks, Inc Employee

I've done it before and you just need to keep track of things very carefully.

Give all the controls that don't change ID's before the ID of your dynamically created controls. (VW doesn't like it when you skip control IDs.)


In the case statement make sure you have events for all of the static controls.

At the end of the case statement you will need an OTHERWISE

Here is where it gets tricky... You have to do some math to figure out which item the user clicked.

You need to be sure the ID is greater than the last static control and less than the last control you created.

In the simplest case you will probably have a label (item=N) and then the hatch control (item=N+1)


You can setup your data structure when you create the dialog so that the dialog item is an index into the structure if you want to keep it simple or with a little more work you can convert the dialog item into an index into a more compact structure.


As you are building the controls for the dialog you need to handle the first control placed after your fixed controls separately and then from then on you iteratively add controls once the pattern is established with the first control.


Done right it works great but it is a little difficult to debug.

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.

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...