Resizing frames with width constraints

时光总嘲笑我的痴心妄想 提交于 2020-01-04 02:02:06

问题


I have simple form TForm1 with 2 panels. First with Align := alLeft and second with Align := alClient and empty frame TFrame1. When i add following procedures to the form, everything works without problems.

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;

But when I set Constrains for TFrame1, for example TFrame1.Contraints.MinWidth := 100 and maximize and restore the form, then the form won't return to its previous state. Regardless of frame size, form size or constrains values, it always ends the same way. In my case default form has 300 width and after maximize and restore it ends with 1062. However without Constraints or FormResize it works. Can someone explain this strange behavior?

来源:https://stackoverflow.com/questions/43201919/resizing-frames-with-width-constraints

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!