How to correctly use AutoSize? lazarus / 31-LCL ---------------------------------------------------------------------- guest65109 · 2020-01-03 13:41 I noticed sometime if I set AutoSize to true the control will disappear on the designer form. It's still there on Components list. After I choose AutoSize to false again it's not reverted back, still disappear. Even if I hit Undo it's still not reappear. How to revert everything back to normal state before I set AutoSize to true? ---------------------------------------------------------------------- howardpc · 2020-01-03 15:51 In the component tree at the top of the object inspector find the hidden control and select it. Then in the object inspector set the control's Top and Left properties to values that bring the control within the borders of its container (form, panel etc.). You may possibly need to reset the Height and Width as well. If that fails, check that the Visible property is not False. ---------------------------------------------------------------------- dsiders · 2020-01-03 16:08 Quote from: howardpc on January 03, 2020, 04:51:57 pmIn the component tree at the top of the object inspector find the hidden control and select it. Then in the object inspector set the control's Top and Left properties to values that bring the control within the borders of its container (form, panel etc.). You may possibly need to reset the Height and Width as well. If that fails, check that the Visible property is not False. You could add setting MinHeight and MinWidth in Constraints to that list too. ---------------------------------------------------------------------- wp · 2020-01-03 16:37 Which component is this? A TLabel? Avoid setting its Caption to an empty string at design time - this will collapse the empty label to zero width. Instead, clear the caption for example in the OnCreate event of the form. ---------------------------------------------------------------------- guest65109 · 2020-01-04 02:37 Quote from: wp on January 03, 2020, 05:37:32 pmWhich component is this? A TLabel? Avoid setting its Caption to an empty string at design time - this will collapse the empty label to zero width. Instead, clear the caption for example in the OnCreate event of the form. It's a TFlowPanel. ---------------------------------------------------------------------- Leledumbo · 2020-01-04 11:37 Read this first to understand how the algorithm works. Ask again when you can't find what you're looking for. Panels are commonly autosized to its contents, so if empty it might be autosized to 0 for both height and width. ---------------------------------------------------------------------- wp · 2020-01-04 12:13 When I add two buttons to a FlowPanel and AutoSize the FlowPanel then, the panel shrinks to zero width. The same with two edit controls. I guess that autosizing of an unanchored or unaligned FlowPanel is not implemented correctly, and posted a bug report (https://bugs.freepascal.org/view.php?id=36514). [EDIT] Fixed in trunk, r62486. If you use the release version open the file lcl/include/customflowpanel.inc or your Lazarus installation, find the procedure TCustomFlowPanel.CalculatePreferredSize and replace it by the following 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 procedure TCustomFlowPanel.CalculatePreferredSize(var PreferredWidth,  PreferredHeight: integer; WithThemeSpace: Boolean);var  xControl: TControl;  xTestRect, xClientRect: TRect;  I: Integer;begin  inherited CalculatePreferredSize(PreferredWidth, PreferredHeight,    WithThemeSpace);   if FControlList.Count > 0 then  begin    xTestRect := Rect(0, 0, 100, 100);    xClientRect := xTestRect;    AdjustClientRect(xClientRect);    for I := 0 to ControlCount-1 do    begin      xControl := FControlList.Items[I].Control;      if FFlowStyle in [fsLeftRightTopBottom, fsRightLeftTopBottom, fsLeftRightBottomTop, fsRightLeftBottomTop] then      begin        PreferredHeight := Max(PreferredHeight,          xControl.BoundsRect.B ottom+xControl.BorderSpacing.Around+xControl.BorderSpacing.Bottom +        xTestRect.Bottom-xClientRect.Bottom- xTestRect.Top+xClientRect.Top);        PreferredWidth := Max(PreferredWidth,          xControl.Width + xControl.BorderSpacing.AroundLeft + xControl.BorderSpacing.AroundRight        );      end else      begin        PreferredWidth := Max(PreferredWidth,          xControl.BoundsRe ct.Right+xControl.BorderSpacing.Around+xControl.BorderSpacing.Right +          xTestRect.Right-xClientRect.Right- xTestRect.Left+xClientRect.Left);        PreferredHeight := Max(PreferredHeight,          xControl.Height + xControl.BorderSpacing.AroundTop + xControl.BorderSpacing.AroundBottom        );      end;    end;  end;end; ---------------------------------------------------------------------- guest65109 · 2020-01-05 10:50 Quote from: wp on January 04, 2020, 01:13:38 pmWhen I add two buttons to a FlowPanel and AutoSize the FlowPanel then, the panel shrinks to zero width. The same with two edit controls. I guess that autosizing of an unanchored or unaligned FlowPanel is not implemented correctly, and posted a bug report (https://bugs.freepascal.org/view.php?id=36514). [EDIT] Fixed in trunk, r62486. If you use the release version open the file lcl/include/customflowpanel.inc or your Lazarus installation, find the procedure TCustomFlowPanel.CalculatePreferredSize and replace it by the following 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 procedure TCustomFlowPanel.CalculatePreferredSize(var PreferredWidth,  PreferredHeight: integer; WithThemeSpace: Boolean);var  xControl: TControl;  xTestRect, xClientRect: TRect;  I: Integer;begin  inherited CalculatePreferredSize(PreferredWidth, PreferredHeight,    WithThemeSpace);   if FControlList.Count > 0 then  begin    xTestRect := Rect(0, 0, 100, 100);    xClientRect := xTestRect;    AdjustClientRect(xClientRect);    for I := 0 to ControlCount-1 do    begin      xControl := FControlList.Items[I].Control;      if FFlowStyle in [fsLeftRightTopBottom, fsRightLeftTopBottom, fsLeftRightBottomTop, fsRightLeftBottomTop] then      begin        PreferredHeight := Max(PreferredHeight,          xControl.BoundsRect.B ottom+xControl.BorderSpacing.Around+xControl.BorderSpacing.Bottom +        xTestRect.Bottom-xClientRect.Bottom- xTestRect.Top+xClientRect.Top);        PreferredWidth := Max(PreferredWidth,          xControl.Width + xControl.BorderSpacing.AroundLeft + xControl.BorderSpacing.AroundRight        );      end else      begin        PreferredWidth := Max(PreferredWidth,          xControl.BoundsRe ct.Right+xControl.BorderSpacing.Around+xControl.BorderSpacing.Right +          xTestRect.Right-xClientRect.Right- xTestRect.Left+xClientRect.Left);        PreferredHeight := Max(PreferredHeight,          xControl.Height + xControl.BorderSpacing.AroundTop + xControl.BorderSpacing.AroundBottom        );      end;    end;  end;end; Thanks