Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto sizing on Form Resize? 1

Status
Not open for further replies.

sijgs

Programmer
Dec 29, 2001
100
CA
I'm trying to resize/relocate all the components on a form:

labels, dropdown boxes, buttons, memoboxes

such that when the form is resized, they all stay in a "proportional" position and size.

Is there some easier way to do this other than "do the math" on every component in an OnResize?

TIA for all hints,
JGS
 
Buho:

Well, SOME movement is noticed, but not what I want... I want all things to stay proportional and they don't. I can't get the left of any item to stay proportional to the form width, and the width of the items are not proportional either (although the width DOES change, it's RADICAL). I've tried every combination of them.

Am I missing something?

Regards,
JGS
 
Make sure you've got your Anchor and Align properties for all your controls set correctly.

Consider using a TPanel control if you need to keep 'blocks' of controls together.

I don't know what you mean by RADICAL, but if you mean that by resizing the form say, widthways that the controls also resize but faster in the same direction, then you may want to try deleting the control and putting it back in. I've seen that before with forms that have somehow gotten corrupt.

If by 'proportional' you mean that you want all your controls to have the space between them grow then you're out of luck - you'll have to do the hard math.
 
Griffyn:

I was afraid of that...

Seems like someone should have put out a unit in freeware by now that would "proportionalize" a form with an init call and then sending each item to it in OnResize. :-/

Tnx,
JGS
 
Well, here's an opportunity for you to gain a bit of immortalization JGS :)

 
Griffyn:

Well, that was an exercise alright....

Only trouble with it is that changing font sizes is "gross" going from 8<->10<->12 versus the pixel changes in the sizes of the items... consequently the font seems to "jump" where the items size very smoothly...

not too bad of a routine if the number of items on a page isn't ghastly...

Thanks for the tips on this.

You wouldn't happen to know if there is a routine that one can use where:

Knowing a form name, you can query the "items" on it (buttons, memo boxes, edit boxes, etc) and their types would you?

Would really be nice if I could just get something like a TString list then I could just feed that to the initialization rtns, and the proportional sizing rtns and not have to code each item in each form in both the FormCreate and OnResize as I have now. (????)

TIA
JGS

 
Anchoring is a work of patience and inspiration (I'm not able to explain how to make it); using the due panels you can drastically change the way your controls are resized/moved... but it is true that anchoring do not solve all problems. Actually, anchoring do not rescale, only resize.

Changing fonts sizes is a dangerous practice, prone to broke due to a lot of factors (user settings the most evident, but some video drivers can play some tricks too, at least in Win 9x).

You can loop trhu the controls and add them to a list. I believe we have some threads dealing with the issue in this forum.

Actually, I don't believe a rescaling component being necessary/useful, as rescaling is not a good practice in Windows (the effect is not worth the many troubles you'll face). Windows is what It is. Bill, in His Infinite Knowledge, made It this way. :) :) :)

buho (A).
 
In fact, (if I'm correct) I believe that the next OS from M$ (looonghorns bullsh*t or something like that... [spin]) will sport real scaling on hardware level (via directx offcourse). I hope this will be a problem less for us, humble programmers :)))

--------------------------------------
What You See Is What You Get
 
That will be very cool (assuming it is not too buggy :).

buho (A).

 
Buho:

If you have any clues on the thread(s) that deal with "looping through the items on a for" I would appreciated it.

I've done a keyword search, and read the entire forums worth of titles to no avail.

TIA
JGS
 
Eh... answered my own question:

Procedure TOCheck_MainF1.List_Components;
Var I : Integer;
TComp : TComponent;
Begin
For I := ComponentCount-1 downto 0 Do
Begin
TComp := Components;
ShowMessage(TComp.Name+' '+TComp.ClassName);
End;
End;

Didn't continue, but each TComp has a component count, etc I guess like a group box with items in it.

JGS
 
Buho(buho (A)):

I'm very interested in your comment:


"Actually, I don't believe a rescaling component being necessary/useful, as rescaling is not a good practice in Windows (the effect is not worth the many troubles you'll face). Windows is what It is. Bill, in His Infinite Knowledge, made It this way."


First, I think the way Delphi (et. al.???) handles resizing of a window to be "archaic" at best. In my development I have NEVER wanted to resize a window and "shut out"/"hide"/"obscure" components.

To me, resizing a window says: resize this thing, and keep everything in sight...

To "window out" components and put scroll bars up, when ScrollBars is set to "none" is LETTING "Bill" get away with what he does. Q.I.P. ? If you resize your desktop, do you get scrollbars and "hidden" things?

So if you don't mind, would you explain your logic on why resizing is "(not) necessary/useful" and "(not) a good practice" ????

And, especially, "the effect is not worth the many troubles you'll face for whatever out of this I'm missing.


JGS

BTW: The routine I wrote does a MAGNIFICENT job of scaling the whole thing just the way I wanted!
 
Learn something new every day. :)

JGS, I just discovered that by setting all the anchor corners to False for the controls on a form, will proportionally resize the empty space between them when you resize the form.

 
jgslater:

I was not talking about resizing but rescaling. :)

Resizing is the usual way Win/Delphi uses to do things, basically when the form size changes and not involving font size changing. Resizing have no direct use in screen definition changes, as it is tied to the form sizes, which in turn are basically not tied to screen resolution (forms can be tied to resolution if you want, but this is not the defined behavior in Win).

Rescaling is about proportional changes in the visual components (width and height), due not only to form size changes but to resolution changes too (auto-rescaling windows changes sizes when resolution changes). Font size changes are a mandatory part of rescaling.

From my experience, rescaling is pretty tricky, and any time you install your program in a new machine you find yourself praying to St. Von Neumann, as some graphics cards can screw up your font management. And Win can play tricks, and user settings can play tricks too.

So, after some tests I dropped rescaling and reverted to normal resizing and anchoring. It is a work of patience (at least for me) but, between some limits, it can be done. Furthermore, most users switching say, from 1024 to 1280 horizontal, are not trying to see bigger things but more things, so scaling up is not what they want.

And yes. If a program designed for 1024 is switched to 640 it will show scroll bars. What is bad. But proportionally rescaling down it to nearly one half is not necesarily better, as some letters can become difficult to read and some icons screwed... and the program was not designed to work in 640 to start with :).

I have no doubt a nearly-perfect rescaling algoritm is possible. What I don not believe is it being worth the work.

Your move :)

buho (A).

 
buho:

I'm trying to build the "programs" that will show/illuminate/demonstrate/ what it is I am trying to accomplish.. in the mean time...

I can't imagine a real developer type saying


"...not worth the effort...."


once you do it.... isn't it "done..." for the most part?

er ahm

??are your "normal" screens so esoteric that you wouldn't want them to gROwShriNk and keep everything "normalized"????

Don't go away.... I'll be "Bach"!

SFIYS
JGS
 
jgslater:

How you will solve icon rescaling? A 20x20 icon designed for 1024 will become a mess when rescaled to 640.

And font rescaling? A font size used in 1024 nearly become glyphs when highly rescaled down.

Step-rescaling can be the way: at some point you throw away one icon set and load another icon set, better suited for the new definition. Same with fonts: at some point you stop rescaling fonts and directly change the font size.

For my needs, it is not worth the work. We can't afford the amount of beta-testing such a code needs to be marked as "OK". You need to check it in different versions of the OS, with different user settings and screen definitions and with different graphic cards. The need to create alternative icon sets need to be taken in account too.

I rather prefer to have my people hunting real bugs and not wasting time changing user settings and switching graphics cards from machine to machine.

I know it depends on the area you are programming for. Due to the nature of my works I can simply ban a resolution. If I believe the program we are working on will not be well suited for some definition I will simply tell the client to get a better monitor and switch to whatever we need.

In my view (of course arguable) resolution is not a thing to be changed every other day. Resolution is defined based on some sensible reasons and not changed until some hardware or software changes makes the resolution switching worth (what is NOT the silly "this card support a highest resolution, lets switch it up" trend you see in some users).

Very respectfully.
buho (A).




 
Buho:

Then I guess it just breaks down to an individuals desire. Too bad though that some "automatic scaling" isn't provided on a wysiwyg as there ISN'T THAT MUCH code to this.

As for "what am I going to do when I try to rescale something like an icon.." for the moment I am setting the autosize parameter to true, and if so, it gets resized(scaled) if false, it's left alone.

I guess there will always be sides to these issues, just like a government.

As for now, I've solved my problem and learned a few ideas and of a few opinions. :)


Regards,
JGS
 
It is for sure I'm not having The Truth (tm) here. The issue is very arguable.

Well... most things in life are. :)

Regards.
buho (A).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top