I have this weird bug in Delphi 13 FMX where the size of the controls is not correct at app startup.
procedure TForm1.AfterConstruction;
begin
inherited AfterConstruction;
btnImageClick(Self);
end;
TAutosizeBubble (based on TRectangle) is parented in a ScrollBox.
procedure TForm1.btnImageClick(Sender: TObject);
begin
VAR Img := TAutosizeBubble.Create(Self);
Img.Parent := ScrollBox.Content;
Img.Stored := FALSE;
Img.Position.Y:= 99999999;
Img.LoadImage('test.jpg', TRect.Create(0, 0, 1344, 768));
ScrollDown;
end;
When created in AfterConstruction/FormCreate/FormShow/etc it does not have the correct height ( 3x larger than it should be). Looks like Width/Height of the form or of ScrollBox is not properly set yet.
However, if I click the button the second time or if I resize the window, the next TAutosizeBubble I create has the correct height!
Even more weird, I realized that if I touch (read) the Form.Width or Form.Height at program startup, the height of the TAutosizeBubble is almost correct (still a few pixels too big, but not 3x larger than it should be). So, if I read (in AfterConstruction) the width form it works.
Any idea on how to fix this, without using a dirty hack?