Flowpanel can rearrange controls at runtime automatically. I don’t know of any other control that can do that. Many people don’t bother with resizing things they just use scrollbox or assume the form will always be large size.
TPanel with AutoSize also just resizes when it's children resize.
The problem with TFlowPanel is that you can't put your component on specific positions. It will always snap to align with the other components. With TPanel you have more freedom regarding positioning.
To test it:
Create new project.
Put a TPanel on the form (make it almost as large as the form)
Put a TButton on the TPanel on the richt-lower side
Put a TMemo on the TPanel on the left-upper side
Make TPanel AutoSize = true
(You see that TPanel snaps to accommodate the components)
Copy and paste the code below completely in and execute.
You can now resize the TMemo with dragging the right-lower corner.
You'll see that TPanel also resizes perfectly.
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls;
type
{ TForm1 }
TSizeableMemo = class(TMemo)
private
FDragging: Boolean;
FLastPos: TPoint;
protected
procedure MouseDown(Button: TMouseButton; Shift:
TShiftState; X, Y: Integer); override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
end;
TMemo = class(TSizeableMemo); // here we just overrule the current TMemo with our own SizeableMemo ;)
TForm1 = class(TForm)
Button1: TButton;
Memo2: TMemo;
Panel1: TPanel;
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
procedure TSizeableMemo.MouseDown(Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if (Button = mbLeft) and ((Width - x ) < 10) and
((Height - y ) < 10) then
begin
FDragging := TRue;
FLastPos := Point(x, y);
MouseCapture := true;
Screen.cursor := crSizeNWSE;
end
else
inherited;
end;
procedure TSizeableMemo.MouseMove(Shift: TShiftState; X, Y: Integer);
var
r: TRect;
begin
if FDragging then
begin
r := BoundsRect;
SetBounds( r.left, r.top, r.right - r.left + X - FlastPos.X,
r.bottom - r.top + Y - Flastpos.Y );
FLastPos := Point( x, y );
end
else
begin
inherited;
if ((Width - x ) < 10) and ((Height - y ) < 10) then
Cursor := crSizeNWSE
else
Cursor := crDefault;
end;
end;
procedure TSizeableMemo.MouseUp(Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if FDragging then
begin
FDragging := False;
MouseCapture := false;
Screen.Cursor := crDefault;
end
else
inherited;
end;
end.