• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 160
  • Last Modified:

How can I code a resizeble form ?

I'd like to have a resizeble form with all of its buttons and listview.
What code I need to add to my form ?
(I'd like to know shortest way to do it)
Thanks.
0
borgo
Asked:
borgo
  • 4
  • 3
  • 2
  • +1
1 Solution
 
bruintjeCommented:
Hi Borgo,

If I understood your question right then this is probably what you're looking for.

I've used this technique for some years, it comes from a delphi book "Delphi How-to".



procedure TResizer.FormCreate(Sender: TObject);
begin
  BH := Height;
  BW := Width;
end;

procedure TResizer.FormResize(Sender: TObject);
var
  AH, AW: Word;
  R: TRect;
  I: Integer;
begin
  AH := Height;
  AW := Width;
  for I := 0 to ComponentCount - 1 do
  if Components[I] is TControl then
  begin
    R := TControl(Components[I]).BoundsRect;
    R.Left := MulDiv(R.Left, AW, BW);
    R.Top := MulDiv(R.Top, AH, BH);
    R.Right := MulDiv(R.Right, AW, BW);
    R.Bottom := MulDiv(R.Bottom, AH, BH);
    TControl(Components[I]).BoundsRect := R;
  end;
  BH := Height;
  BW := Width;
end;

Hope this helps.
Good luck
Bruintje

0
 
viktornetCommented:
I have a componenta that might helpp
0
 
bryan7Commented:
I have a panel that resizes all the components on it when it's resized.

bryan
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
viktornetCommented:
borgo. Did the component I sent you worked?? If yes, I'd appreciate to get the credit.. If not then let someone have it..

Cheers,
Viktor
0
 
borgoAuthor Commented:
Bryan 7:  Please send me you panel ? Is it free and with source ? I'll use it in the application which  I'll do for my next exam.

Viktornet: I haven't tried your component yet. I'll inform you early. Thanks again.

Bruintje: Yes it works. But is not a too simple solution ? What do you think about ? Thank you.


0
 
bruintjeCommented:
Hi Borgo,

It is a short way in the KISS way.

Bruintje.
0
 
borgoAuthor Commented:
Bruintje:
What is KISS way ? :-)
You'll get your points.
Thank you for your answer.
It will be very usefull to me.
0
 
bruintjeCommented:
Hi Borgo,

Hum.. "Keep It Simple Stupid".
Learned the hard way that doing things simple is a way of keeping up in real life. If you have done that long enough you can buy yourself the time to create more beautiful(complex) things, making life worth living.

Bruintje.


0
 
bruintjeCommented:
Hi again,

In addition to my previous comment, I think you should use the solution that's most suitable for the needs. If you had to make only some components resizing at a given action (couldn't think of an example, maybe zooming? :) )then it would be simpler to use a component that turns on or off the resizing capabillities of selected components.
0
 
borgoAuthor Commented:
You're right. :-)

Thanks.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now