PDA

Click to See Complete Forum and Search --> : Adding Shapes during runtime


jyeadon
Jan 19th, 2002, 01:39 PM
I need to add multiple shapes to my form during runtime . I would like to add these shapes as a dynamic control array. Any ideas from anyone?? Thanks in advance for any help.

TeDiouS
Jan 20th, 2002, 05:42 AM
I need to draw rectangles on the screen at run time - a maximum of 640 of them. The trouble is, they need to fit in with some legacy code from previous versions of the program. :rolleyes:

Basically, depending on the status of a variable in an array, the program needs to be able to draw or remove a rectangle after the user clicks on the appropriate position on the form.

The click-detection code, I can do. Getting the correct place for the rectangle to go (or disappear from), I can do.

Actually getting it to:
a) Draw the right colour rectangle in the right place
b) Remove the CORRECT rectangle after another click

- is beyond me.

HELP! :D

Sastraxi
Jan 20th, 2002, 04:48 PM
When you want to load another member, use this code:Load Picture1(Picture1.UBound + 1)I find this code very useful as it will find the last index in the control array and make one with an index one higher. Then you treat it like a normal control. To be able to do this, set a picturebox (eg. picture1)'s index property to 0. In a command button, run this code and (for example) randomize the left and top, maybe the width and height too.

Sastraxi
Jan 20th, 2002, 04:49 PM
You can then save the index of the newly created control, and when it's clicked on again, make it invisible (or unload it)...Picture1(ThisIndex).Visible = False
Unload Picture1(ThisIndex)Cheers!

jyeadon
Jan 21st, 2002, 05:56 PM
Thanks for the help everyone. Much appreciated