Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Dec 15, 2019 11:25 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Control size and placement as a percentage?
PostPosted: Thu Feb 24, 2011 9:54 am 
Offline

Joined: Thu Jun 17, 2010 2:49 pm
Posts: 83
Positioning and sizing controls is kind of difficult in RealBasic. Especially when screen size is going to be variable. Is there a way to set a control's width or location to a percentage of the window's width? What tips do you have?

_________________
RealStudio user.


Top
 Profile  
Reply with quote  
 Post subject: Re: Control size and placement as a percentage?
PostPosted: Thu Feb 24, 2011 10:28 am 
Offline

Joined: Sat Mar 25, 2006 1:39 pm
Posts: 894
Location: Morgan Hill, CA
8rad wrote:
Positioning and sizing controls is kind of difficult in RealBasic. Especially when screen size is going to be variable. Is there a way to set a control's width or location to a percentage of the window's width? What tips do you have?

While I've never done it, I'd think that you could put code to recalculate the sizes and positions of the the controls into the window's Resizing event. By doing the calculations based on the current value of the window's Width property, you should be able to grow and shrink them as the window's width is changed.

_________________
While fairly new to RB, I've been programming ever since that darned mastadon stepped on my abacus. Using RB 2009r5.1 on XP and Windows 7.


Top
 Profile  
Reply with quote  
 Post subject: Re: Control size and placement as a percentage?
PostPosted: Thu Feb 24, 2011 2:47 pm 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
Isn't this what the (LockTop|LockBottom|LockLeft|LockRight) property is for? Maintaining proportional sizes and distances?

_________________
Boredom Software


Top
 Profile  
Reply with quote  
 Post subject: Re: Control size and placement as a percentage?
PostPosted: Thu Feb 24, 2011 2:56 pm 
Offline

Joined: Wed May 20, 2009 4:43 pm
Posts: 958
charonn0 wrote:
Isn't this what the (LockTop|LockBottom|LockLeft|LockRight) property is for? Maintaining proportional sizes and distances?

No, it doesn't scale the controls proportionally - it maintains the space from the locked side.

_________________
RB 2009r4 Windows XP


Top
 Profile  
Reply with quote  
 Post subject: Re: Control size and placement as a percentage?
PostPosted: Thu Feb 24, 2011 2:58 pm 
Offline

Joined: Mon Aug 14, 2006 9:33 pm
Posts: 1774
Quote:
Isn't this what the (LockTop|LockBottom|LockLeft|LockRight) property is for?


In a very simple GUI, yes, using the "lock" features will work. But in a more complex GUI it won't. For instance, 2 buttons side by side: set lock left and lock right on both: expand the width of the screen. The left button will "overdraw" part of the right button.
There is no easy code for this. Use the Window.Resized event and "do the math" to reposition your controls where you want them after the resize.

_________________
Roger Clary
Class One Software
Educational Software for Lifelong Learning
http://www.classonesoftware.com


Top
 Profile  
Reply with quote  
 Post subject: Re: Control size and placement as a percentage?
PostPosted: Thu Feb 24, 2011 3:53 pm 
Offline

Joined: Sat Mar 25, 2006 1:39 pm
Posts: 894
Location: Morgan Hill, CA
classone wrote:
Quote:
Isn't this what the (LockTop|LockBottom|LockLeft|LockRight) property is for?


In a very simple GUI, yes, using the "lock" features will work. But in a more complex GUI it won't. For instance, 2 buttons side by side: set lock left and lock right on both: expand the width of the screen. The left button will "overdraw" part of the right button.
There is no easy code for this. Use the Window.Resized event and "do the math" to reposition your controls where you want them after the resize.

While I'm sure doing that would work, the user wouldn't be able to any of the changes until the window resizing was completed. Unless the screen flickers too much doing so, I'd think it would be better to do the scaling and positioning as the window is being resized in the Resizing event, rather than afterward in the Resized event. (The choice may depend on the number of controls that you have to deal with.)

_________________
While fairly new to RB, I've been programming ever since that darned mastadon stepped on my abacus. Using RB 2009r5.1 on XP and Windows 7.


Top
 Profile  
Reply with quote  
 Post subject: Re: Control size and placement as a percentage?
PostPosted: Thu Feb 24, 2011 4:51 pm 
Offline

Joined: Mon Aug 14, 2006 9:33 pm
Posts: 1774
Quote:
do the scaling and positioning as the window is being resized in the Resizing event

Which, in my experience, causes intolerable flickering on Win. YMMV

_________________
Roger Clary
Class One Software
Educational Software for Lifelong Learning
http://www.classonesoftware.com


Top
 Profile  
Reply with quote  
 Post subject: Re: Control size and placement as a percentage?
PostPosted: Thu Feb 24, 2011 5:04 pm 
Offline

Joined: Sat Mar 25, 2006 1:39 pm
Posts: 894
Location: Morgan Hill, CA
classone wrote:
Quote:
do the scaling and positioning as the window is being resized in the Resizing event

Which, in my experience, causes intolerable flickering on Win. YMMV

Thank you, that's a good reason to use the Resized event. (I mentioned that possibility in the sentence you quoted.)

Is the amount of flickering reasonable if there are just a few controls on the window or is the flickering always intolerable?

_________________
While fairly new to RB, I've been programming ever since that darned mastadon stepped on my abacus. Using RB 2009r5.1 on XP and Windows 7.


Top
 Profile  
Reply with quote  
 Post subject: Re: Control size and placement as a percentage?
PostPosted: Thu Feb 24, 2011 5:26 pm 
Offline

Joined: Mon Aug 14, 2006 9:33 pm
Posts: 1774
Quote:
Is the amount of flickering reasonable if there are just a few controls on the window or is the flickering always intolerable?

I always had several controls on the screen, so it was always bad. Don't know if there are techniques to avoid the flicker, probably so, but my solution of waiting until the resize was done before re-positioning worked for me.

_________________
Roger Clary
Class One Software
Educational Software for Lifelong Learning
http://www.classonesoftware.com


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group