LCL: fix autosizing for not-aligned controls. Issue #28654

git-svn-id: trunk@56947 -
This commit is contained in:
ondrej 2018-01-04 06:24:36 +00:00
parent 8726ea2759
commit 9ecac75432
2 changed files with 17 additions and 16 deletions

View File

@ -3025,28 +3025,27 @@ procedure TControl.DoAllAutoSize;
var
AWinControl: TWinControl;
i: Integer;
Needed: Boolean;
begin
if AControl.AutoSizeDelayed then exit;
Needed:=cfAutoSizeNeeded in AControl.FControlFlags;
//DebugLn(['TControl.DoAllAutoSize.AutoSizeControl ',DbgSName(AControl),' AutoSize=',AControl.AutoSize,' IsControlVisible=',AControl.IsControlVisible,' cfAutoSizeNeeded=',Needed]);
Exclude(AControl.FControlFlags, cfAutoSizeNeeded);
if not AControl.IsControlVisible then exit;
if Needed and AControl.AutoSize and
(not ((AControl.Parent = nil) and (csDesigning in AControl.ComponentState)))
then
AControl.DoAutoSize;
if AControl is TWinControl then
if AControl.IsControlVisible then
begin
// recursive
AWinControl := TWinControl(AControl);
//DebugLn(['AutoSizeControl ',DbgSName(AWinControl)]);
AWinControl.AlignControl(nil);
for i := 0 to AWinControl.ControlCount - 1 do
AutoSizeControl(AWinControl.Controls[i]);
if (cfAutoSizeNeeded in AControl.FControlFlags) and AControl.AutoSize and
(not ((AControl.Parent = nil) and (csDesigning in AControl.ComponentState)))
then
AControl.DoAutoSize;
if AControl is TWinControl then
begin
// recursive
AWinControl := TWinControl(AControl);
//DebugLn(['AutoSizeControl ',DbgSName(AWinControl)]);
AWinControl.AlignControl(nil);
for i := 0 to AWinControl.ControlCount - 1 do
AutoSizeControl(AWinControl.Controls[i]);
end;
end;
Exclude(AControl.FControlFlags, cfAutoSizeNeeded);
end;
function CallAllOnResize(AControl: TControl): boolean;

View File

@ -2554,6 +2554,8 @@ var
CurControl: TControl;
begin
Result := True;
if cfAutoSizeNeeded in FControlFlags then
Exit;
for I := ControlCount - 1 downto 0 do
begin
CurControl:=Controls[I];