Resizing frames with width constraints

I have a simple form TForm1

with 2 panels. First with Align := alLeft

, and the second with Align := alClient

and an empty frame TFrame1

. When I add the following procedures to the form, everything works without issue.

procedure TForm1.FormCreate(Sender: TObject);
var
  lFrame1, lFrame2 : TFrame1;
begin
  lFrame1 := TFrame1.Create(nil);
  lFrame1.Parent := pnl1;
  lFrame1.Align  := alClient;
  lFrame2 := TFrame1.Create(nil);
  lFrame2.Parent := pnl2;
  lFrame2.Align  := alClient;
end;

procedure TForm1.FormResize(Sender: TObject);
begin
  pnl1.Width := ClientWidth div 2;
end;

      

enter image description here

But when I set Constrains

for TFrame1

, for example TFrame1.Contraints.MinWidth := 100

and maximize and restore the shape, the shape does not revert to its previous state. No matter the frame size, size, or size constraints, it always ends up the same way. In my case, the form defaults to 300 and after maximizing and restoring ends at 1062. However, without Constraints

or FormResize

it works. Can anyone explain this strange behavior?

enter image description here

+3


source to share





All Articles