New topic: 

for and next loops for doing thigs with controls

<http://forums.realsoftware.com/viewtopic.php?t=47611>

         Page 1 of 1
   [ 5 posts ]                 Previous topic | Next topic          Author  
Message        seanclancy          Post subject: for and next loops for doing 
thigs with controlsPosted: Tue Apr 16, 2013 1:47 pm                         
Joined: Fri Jan 08, 2010 9:59 am
Posts: 304                Hi there... I'm doing a resizing of my man window and 
I used the below code to move all my controls to the right places however the 
main window is resized.
 

  Dim ctl as RectControl
  for k=0 to ControlCount-1
  ctl = RectControl( control(k) )
  ctl.left=ctl.left+i
  ctl.top=ctl.top+j
  next

However, this graps all rectcontrols...

Is there a way to grab every single type of control rather than rectcontrol?   
                             Top                Dale          Post subject: Re: 
for and next loops for doing thigs with controlsPosted: Tue Apr 16, 2013 2:15 
pm                                 
Joined: Thu Mar 01, 2007 2:02 pm
Posts: 232
Location: Sunny (generally!) Southern California                I don't know 
the layout of your controls but have you tried just using the LockTop, 
LockLeft, LockRight, and LockBottom parameters?  By setting a control's 
LockBottom and LockRight the control's position will be moved as the bottom or 
right side of the window is changed. If you want the control to grow as the 
window is widened, set both LockLeft and LockRight.

I don't know if this will do it for you but it's easier than trying to manually 
move the controls.

- Dale      
_________________
-----
Real Studio 2012r1 on Windows 7 (64 bit)
-----
It has been said that politics is the second oldest profession. 
I have learned that it bears a striking resemblance to the first.
 - Ronald Reagan  
                             Top                seanclancy          Post 
subject: Re: for and next loops for doing thigs with controlsPosted: Tue Apr 
16, 2013 2:25 pm                         
Joined: Fri Jan 08, 2010 9:59 am
Posts: 304                Not in this case...  The backdrop is really dependant 
on screensize and paints itself in a different way to accomodate it's extremely 
beautiful (:)) graphics for the screen size...

here's my code:

me.Width=screen(0).AvailableWidth
me.Height=screen(0).AvailableHeight
bd=new picture (me.Width,me.Height,32)
dim g as Graphics
g=bd.Graphics
dim j,i,k as integer
if me.Height<1080 then j=0-(1080-me.Height)
if 1080-me.Height>260 then j=-260
i=0-((1920-me.Width)/2)
g.DrawPicture(StartPage,i,j)
me.backdrop=bd

Dim ctl as RectControl
for k=0 to ControlCount-1
  ctl = RectControl( control(k) )
  ctl.left=ctl.left+i
  ctl.top=ctl.top+j
next


what I need is a way to select every single type of control (like group boxs, 
radiobuttons, canvases inside canvases etc...)

I tried
Dim ctl as Control
for k=0 to ControlCount-1
  ctl = control(k)
  ctl.left=ctl.left+i
  ctl.top=ctl.top+j
next


but that didn't work   
                             Top                doofus          Post subject: 
Re: for and next loops for doing thigs with controlsPosted: Tue Apr 16, 2013 
3:20 pm                                 
Joined: Thu Sep 10, 2009 2:50 am
Posts: 400
Location: Santa Cruz, CA, USA                seanclancy wrote:what I need is a 
way to select every single type of control (like group boxs, radiobuttons, 
canvases inside canvases etc...)

If you want only RectControls you should check that it is a RectControl
Dim ctl as RectControl
for k=0 to ControlCount-1
  if Not Control(k) IsA RectControl then Continue for k
  ctl = RectControl(control(k))
  //...
next



seanclancy wrote:I tried
Dim ctl as Control
for k=0 to ControlCount-1
  ctl = control(k)
  ctl.left=ctl.left+i
  ctl.top=ctl.top+j
next


but that didn't work
How doesn't that work? Oh wait, just tested and I don't get non-RectControls 
listed (Timer and ServerSocket). That's a bug by the documentation. This is 
happening in my 2009r3 copy of RS too; a long standing bug??

Edit: Timers and ServerSockets aren't a Control subclass so that's not a bug. 
My mistake. The only direct subclasses of Control (that I know of) are 
NotePlayer and RectControl.

But if you want only RectControls your loop should be working. An exception is 
ContainerControls, not sure how to loop over those.   
                             Top                seanclancy          Post 
subject: Re: for and next loops for doing thigs with controlsPosted: Tue Apr 
16, 2013 4:59 pm                         
Joined: Fri Jan 08, 2010 9:59 am
Posts: 304                I got it working...
It meant I have to skip putting things in groupboxes and canvases otherwise 
they would be totally out of wack.
It also meant lots of dirty coding - but hey, it works 
Thanks for the help I haven't dealt much with runtime code using rectcontrls 
(well not using "rectcontrols")
Sean   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 5 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to