Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Randomly Moving Controls
Message
 
To
20/09/2000 15:38:45
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00418697
Message ID:
00418968
Views:
29
MyContatiner.MyArray(15,3)
1 -[N] - .top
2 -[N] - .left
3 -[L] - assigned
MyContainer.Init

*!* Step Through the controls (if you have more controls than the buttons, you may need to alter this)
FOR lnObjCount = 1 TO THIS.ControlCount
  lnRow = INT(RAND(0)*15)  && randomly select row 
  DO WHILE THIS.MyArray(lnRow,3)
    *!*  since row has already been assigned, randomly select another row 
    lnRow = INT(RAND(0)*15)
  LOOP
  *!*  set properties for buttons
  THIS.Controls(lnObjCount).Top = THIS.MyArray(lnRow,1)
  THIS.Controls(lnObjCount).Left = THIS.MyArray(lnRow,2)
  THIS.MyArray(lnRow,3) = .T.
ENDFOR

THIS.Visible = .T.
THIS.Refresh
Bear in mind, that this is quite simple and the DO LOOP could potentially drag on when attempting to assign the last row or two.

You could also set up the coordinates in a table and assign an index key at run time. This would ensure that it would be quicker.

HTH
I try to stay online, to get better information.
I try to get away from the office once in a while..
But they KEEP... PULLING.. ME.. BACK.. IN!!!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform