unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
procedure NewFormActivate(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var
f: TForm;
e: TEdit;
begin
f := TForm.CreateNew(Self);
e := TEdit.Create(f);
try
e.Parent := f;
f.Constraints.MinWidth := 300;
f.OnActivate := @NewFormActivate;
f.ShowModal;
finally
f.Free;
end;
end;
procedure TForm1.NewFormActivate(Sender: TObject);
var
h: Integer;
begin
if not(Sender is TForm) then Exit;
with (Sender as TForm) do
begin
AutoSize := True;
h := Height;
AutoSize := False;
Height := h;
end;
end;
end.