Board index » cppbuilder » Resize the window but aspect ratio remain constant?

Resize the window but aspect ratio remain constant?


2007-05-14 08:15:35 PM
cppbuilder87
hi,
I want to resize the window but inside windows objects aspect ratio remain constant.....
Like I have on form . On form i placed one panel.I fixed
the width and height of panel.
When i resize the window , the panel should also be
resized according to form resize but its aspect
ratio(width/height) remain constant....
Please help me
-------
Thanks
Peter Jackson
 
 

Re:Resize the window but aspect ratio remain constant?

Hi Peter,
I'd recommend the following:
1: Calculate the aspect ratio.
2: When the user (or whatever) resizes
the window, calculate the change in size
but adjust the size according to the
aspect ratio that you calculated in step
one. Bias either the width or height
(your choice).
Example:
Window starts at 200 x 160.
200 / 160 = 1.25 <-- your aspect ratio.
Window is resized to 360 x 230.
Bias via height. 230 x 1.25 = 287.5.
Round up to 288.
Set window to 288 x 230.
HTH,
Bruce