Real Software Forums
http://forums.realsoftware.com/

Control size and placement as a percentage?
http://forums.realsoftware.com/viewtopic.php?f=1&t=37809
Page 1 of 1

Author:  8rad [ Thu Feb 24, 2011 9:54 am ]
Post subject:  Control size and placement as a percentage?

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?

Author:  bob_barr [ Thu Feb 24, 2011 10:28 am ]
Post subject:  Re: Control size and placement as a percentage?

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.

Author:  charonn0 [ Thu Feb 24, 2011 2:47 pm ]
Post subject:  Re: Control size and placement as a percentage?

Isn't this what the (LockTop|LockBottom|LockLeft|LockRight) property is for? Maintaining proportional sizes and distances?

Author:  markwalsh [ Thu Feb 24, 2011 2:56 pm ]
Post subject:  Re: Control size and placement as a percentage?

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.

Author:  classone [ Thu Feb 24, 2011 2:58 pm ]
Post subject:  Re: Control size and placement as a percentage?

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.

Author:  bob_barr [ Thu Feb 24, 2011 3:53 pm ]
Post subject:  Re: Control size and placement as a percentage?

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

Author:  classone [ Thu Feb 24, 2011 4:51 pm ]
Post subject:  Re: Control size and placement as a percentage?

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

Author:  bob_barr [ Thu Feb 24, 2011 5:04 pm ]
Post subject:  Re: Control size and placement as a percentage?

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?

Author:  classone [ Thu Feb 24, 2011 5:26 pm ]
Post subject:  Re: Control size and placement as a percentage?

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.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/