From 3b529ee86e3dab844bada13321249f76eafba89d Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 10 Jul 2017 12:50:21 +0000 Subject: [PATCH] anchordocking: fixed hiding docksite when last control gets Visible=false git-svn-id: branches/fixes_1_8@55483 - --- components/anchordocking/anchordocking.pas | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/components/anchordocking/anchordocking.pas b/components/anchordocking/anchordocking.pas index a7fc9278a8..5f1ba602a9 100644 --- a/components/anchordocking/anchordocking.pas +++ b/components/anchordocking/anchordocking.pas @@ -272,6 +272,7 @@ type Inside: boolean): boolean; virtual; function DockAnotherControl(Sibling, NewControl: TControl; DockAlign: TAlign; Inside: boolean): boolean; virtual; + procedure ChildVisibleChanged(Sender: TObject); virtual; procedure CreatePages; virtual; procedure FreePages; virtual; function DockSecondPage(NewControl: TControl): boolean; virtual; @@ -3378,6 +3379,31 @@ begin FHeaderSide:=AValue; end; +procedure TAnchorDockHostSite.ChildVisibleChanged(Sender: TObject); +var + AControl: TControl; +begin + if Sender is TControl then begin + AControl:=TControl(Sender); + if not (csDestroying in ComponentState) then begin + if (not AControl.Visible) + and (not ((AControl is TAnchorDockHeader) + or (AControl is TAnchorDockSplitter) + or (AControl is TAnchorDockHostSite))) + then begin + //debugln(['TAnchorDockHostSite.ChildVisibleChanged START ',Caption,' ',dbgs(SiteType),' ',DbgSName(AControl),' UpdatingLayout=',UpdatingLayout]); + if (SiteType=adhstOneControl) then + Hide + else if (SiteType=adhstLayout) then begin + RemoveControlFromLayout(AControl); + UpdateDockCaption; + end; + //debugln(['TAnchorDockHostSite.ChildVisibleChanged END ',Caption,' ',dbgs(SiteType),' ',DbgSName(AControl)]); + end; + end; + end; +end; + procedure TAnchorDockHostSite.Notification(AComponent: TComponent; Operation: TOperation); begin @@ -4896,6 +4922,7 @@ begin //debugln(['TAnchorDockHostSite.RemoveControl ',DbgSName(Self),'=',Caption,' ',DbgSName(AControl)]); DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TAnchorDockHostSite.RemoveControl'){$ENDIF}; try + AControl.RemoveHandlerOnVisibleChanged(@ChildVisibleChanged); inherited RemoveControl(AControl); if not (csDestroying in ComponentState) then begin if (not ((AControl is TAnchorDockHeader) @@ -4924,6 +4951,7 @@ begin or (AControl is TAnchorDockHeader)) then UpdateDockCaption; + AControl.AddHandlerOnVisibleChanged(@ChildVisibleChanged); finally EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TAnchorDockHostSite.InsertControl'){$ENDIF}; end;