Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Tue May 23, 2017 3:58 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: howto resize 2 controls side by side relative to each other
PostPosted: Thu Apr 05, 2012 12:08 pm 
Offline

Joined: Wed Apr 04, 2012 5:34 am
Posts: 51
Hi all,

I have only been using real basic for a week now, so please don't flame me if this is no good.
I have noticed a lot of posts regarding getting 2 controls that are side by side to resize relative to each other with proportionate spacing.

This is my work around.

Assuming window with which you wish to do this is called MainWindow.

First in the window with which you wish to do this, add 2 properties. lastwidth and widthcount. Both being integer and set to 0.
In the open event of the window place code:

lastwidth = MainWindow.width

Then in the resized event place code:

dim wv as integer
wv=widthcount+MainWindow.width-lastwidth
if wv = 1 then
widthcount = 1
lastwidth = MainWindow.width
else
if bitwise.bitAnd(wv,&h01) <> 0 then
' number is odd
wv = wv - 1
widthcount = 1
'do resize
'first field + label + second field
FirstField.width = FirstField.width + (wv/2)
SecondField.width = SecondField.width + (wv/2)
SecondField.left = SecondField.left + (wv/2)
label.left = label.left + (wv/2)
'end line
lastwidth = MainWindow.width
else
' number is even
widthcount = 0
'do resize
'first field + label + second field
FirstField.width = FirstField.width + (wv/2)
SecondField.width = SecondField.width + (wv/2)
SecondField.left = SecondField.left + (wv/2)
label.left = label.left + (wv/2)
'end line
lastwidth = MainWindow.width
end if
end if

Thats it. The textfield boxes in this case will resize correctly and the labels placed before the second textfield moves along with it. All while keeping the spacing.

Notes, FirstField should be locked left while label and SecondField should not be locked either left or right.
Just repeat the code:

FirstField.width = FirstField.width + (wv/2)
SecondField.width = SecondField.width + (wv/2)
SecondField.left = SecondField.left + (wv/2)
label.left = label.left + (wv/2)

for each row of controls you wish to do this to.

Some smart person may wish to add a method to make this simpler. e.g. resizeboxes(FirstField,label,SecondField) or something like that. If someone does, please reply with the method here.

Credit to Norman Palardy for the even/odd checking code and Dave Wooldridge for revising the even/odd checking code.


Top
 Profile  
 
 Post subject: Re: howto resize 2 controls side by side relative to each ot
PostPosted: Thu Apr 05, 2012 12:16 pm 
Offline

Joined: Wed Apr 04, 2012 5:34 am
Posts: 51
I should mention, this works perfectly in Mac OSX. In windows, you need to add the same code in the resized event into the resizing event to get it to resize on-the-fly.


Top
 Profile  
 
 Post subject: Re: howto resize 2 controls side by side relative to each ot
PostPosted: Thu Apr 05, 2012 2:15 pm 
Offline

Joined: Thu Dec 01, 2011 2:13 pm
Posts: 288
awillyan wrote:
I should mention, this works perfectly in Mac OSX. In windows, you need to add the same code in the resized event into the resizing event to get it to resize on-the-fly.

If you have LiveResize true on mac, you also have to do this there. But a great tip! Thnx!

_________________
Mac OS X 10.3-10.8
Windows 2000 (I know it sucks)
Windows Server 2007

You want a bunch of new classes and web styles? realstudiodevspot.com (search there for Web Styles Plugin)
Folderitem is too hard? File Bin Class
I hate cows.


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

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


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