mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 12:18:03 +02:00
AnchorDocking: Fixed SimplifyOneControl destroy the layout, Issue #34937
git-svn-id: trunk@60206 -
This commit is contained in:
parent
1e95857ce7
commit
3d405210f9
@ -4789,7 +4789,7 @@ procedure TAnchorDockHostSite.SimplifyOneControl;
|
||||
var
|
||||
Site: TAnchorDockHostSite;
|
||||
i: Integer;
|
||||
Child: TControl;
|
||||
Child, PlaceHolder: TControl;
|
||||
a: TAnchorKind;
|
||||
begin
|
||||
if SiteType<>adhstOneControl then exit;
|
||||
@ -4813,11 +4813,22 @@ begin
|
||||
|
||||
Site.BeginUpdateLayout;
|
||||
// move controls from Site to Self
|
||||
// when a site is moved to a other parent, we have to insert a place holder
|
||||
// on old site or the splitters will be removed, see issue #34937
|
||||
i:=Site.ControlCount-1;
|
||||
while i>=0 do begin
|
||||
Child:=Site.Controls[i];
|
||||
if Child.Owner<>Site then begin
|
||||
//debugln(['TAnchorDockHostSite.SimplifyOneControl Self="',Caption,'" Child=',DbgSName(Child),'="',Child.Caption,'"']);
|
||||
if (Child.Owner<>Site) then begin
|
||||
if not (Child is TAnchorDockSplitter) then begin
|
||||
PlaceHolder:=TAnchorDockHostSite.CreateNew(Site);
|
||||
PlaceHolder.Parent:=Site;
|
||||
PlaceHolder.Anchors:=Child.Anchors;
|
||||
for a:=Low(TAnchorKind) to High(TAnchorKind) do
|
||||
PlaceHolder.AnchorSide[a].Control:=Child.AnchorSide[a].Control;
|
||||
PlaceHolder.SetBounds(Child.Left, Child.Top, Child.Width, Child.Height);
|
||||
PlaceHolder.Name:='_'+Child.Name;
|
||||
PlaceHolder.Visible:=Child.Visible;
|
||||
end;
|
||||
Child.Parent:=Self;
|
||||
if Child=Site.Pages then begin
|
||||
FPages:=Site.Pages;
|
||||
@ -4832,6 +4843,15 @@ begin
|
||||
end;
|
||||
i:=Min(i,Site.ControlCount)-1;
|
||||
end;
|
||||
|
||||
for i:=0 to ControlCount-1 do begin
|
||||
Child:=Controls[i];
|
||||
PlaceHolder:=TControl(Site.FindComponent('_'+Child.Name));
|
||||
if not Assigned(PlaceHolder) then continue;
|
||||
for a:=Low(TAnchorKind) to High(TAnchorKind) do
|
||||
if PlaceHolder.AnchorSide[a].Control<>Site then
|
||||
Child.AnchorSide[a].Control:=PlaceHolder.AnchorSide[a].Control;
|
||||
end;
|
||||
Site.EndUpdateLayout;
|
||||
|
||||
// delete Site
|
||||
|
Loading…
Reference in New Issue
Block a user