TForm.CreateNew Maximize Issue lazarus / 31-LCL ---------------------------------------------------------------------- M+AUDIO · 2017-07-17 07:45 Hello, A TForm created with CreateNew  constructor with AutoSize and MinSize and a control inside, refuses to maximize on win32 widgetset. It will maximize however, after you resize the form by dragging borders a bit. but this is not correct. Sample project attached. Lazarus SVN 32133 windows 7. ---------------------------------------------------------------------- Handoko · 2017-07-17 08:17 I tested your code on both Linux64 and Win32 (using Wine). On Linux, it works as it should be. And yes, your issue happened on my test on Win32. I found that the problem only happened if the form calls AutoSize. So the quick fix for it is to use Height instead of AutoSize. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 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.Height := e.Top + e.Height;    //f.AutoSize := True;   // <=== Remove the comment and the issue will come back    f.ShowModal;  finally    f.Free;  end;end; ---------------------------------------------------------------------- M+AUDIO · 2017-07-17 09:00 Of course Handoko, You can comment out  MinSize instead of AutoSize and it works too. But the issue is still hiding back there. Now you Confirmed it, it needs to be reported on the bug tracker, I guess. P.S. The reason I use TForm.AutoSize and alTop-ed controls inside for some small dynamic forms is High-DPI support. and it works really really good and automatic. (except this Maximize issue). ---------------------------------------------------------------------- Handoko · 2017-07-17 09:55 I managed to make it works the way you want. Try the code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 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. It works on my tests, it should work on your computer too. But I agree, there is a bug in AutoSize. ---------------------------------------------------------------------- taazz · 2017-07-17 10:06 Just to be clear. The bug is that the form maximizes with autosize set to true. It should not do that. ---------------------------------------------------------------------- Handoko · 2017-07-17 10:14 Form maximize + autosize behaves differently: - On Linux, autosized form can be maximized - On Windows, autosized form cannot be maximized ---------------------------------------------------------------------- taazz · 2017-07-17 10:15 Quote from: Handoko on July 17, 2017, 12:14:10 pmForm maximize + autosize behaves differently: - On Linux, autosized form can be maximized - On Windows, autosized form cannot be maximized linux has a bug. Autosize by design should not allow resizing the form. The only exception is when the form bigger than the supported size of the underline widget set (ee bigger that the desktop area in windows) in which case it will look like maximized but it should not be. ---------------------------------------------------------------------- M+AUDIO · 2017-07-17 10:29 Quote from: taazz on July 17, 2017, 12:15:32 pmlinux has a bug. Autosize by design should not allow resizing the form.But why? Delphi compatibility? IMHO it is better to allow resize. though the name AutoSize suggests otherwise. @Handoko Yes that works, Thank you. ---------------------------------------------------------------------- taazz · 2017-07-17 11:21 Quote from: M+AUDIO on July 17, 2017, 12:29:19 pmQuote from: taazz on July 17, 2017, 12:15:32 pmlinux has a bug. Autosize by design should not allow resizing the form.But why? Delphi compatibility? IMHO it is better to allow resize. though the name AutoSize suggests otherwise. Autosize and maximize are opposites. even partially maximized eg altop/left etc is outside the scope of autosize but could be interpreted as autosize the free to size dimension. maximize/alclient leave no free dimensions to size so you have to choose. maximize or autosize? it can't do both. If you leave it undefined then both actions are probable and you should not depend on either behavior. ---------------------------------------------------------------------- Ondrej Pokorny · 2017-07-18 15:40 Quote from: M+AUDIO on July 17, 2017, 09:45:32 amLazarus SVN 32133 windows 7. Why so old? The current revision is 55526. ---------------------------------------------------------------------- M+AUDIO · 2017-07-19 07:40 Quote from: Ondrej Pokorny on July 18, 2017, 05:40:06 pmQuote from: M+AUDIO on July 17, 2017, 09:45:32 amLazarus SVN 32133 windows 7. Why so old? The current revision is 55526. Wow that was way off!  Actually, I'm on 55489 (updated just before posting that). but somehow mysteriously I've wrote the number from Bug-ID column in TortoiseSVN's Show Log window. Now I've reported it.