I want to take this post to suggest a change in the theme of "anchordocking" which to me makes it more useful and elegant.
Paint headers "TAnchorDockHeader" with a solid color and highlighted in the "TAnchorDockHostSite" to have focus.
To do this I modified the following code:
Add a public field to the class "TAnchorDockHeader":
public
HeaderColor:TColor;
initialize the field to default value:
constructor TAnchorDockHeader.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
HeaderColor:=TColor($00F4EBE3);
"
"
Add two overriding methods DoExit and DoEnter to the class "TAnchorDockHostSite":
procedure TAnchorDockHostSite.DoEnter;
begin
inherited DoEnter;
FHeader.HeaderColor:=TColor($00F3CCA8);
FHeader.Invalidate;
end;
procedure TAnchorDockHostSite.DoExit;
begin
inherited DoExit;
FHeader.HeaderColor:=TColor($00F4EBE3);
FHeader.Invalidate;
end;
and modify the method "Paint" of class "TAnchorDockHeader":
procedure TAnchorDockHeader.Paint;
var
r: TRect;
TxtH: longint;
TxtW: longint;
dx,dy: Integer;
begin
r:=ClientRect;
Canvas.Frame3d(r,1,bvRaised);
Canvas.Brush.Color:=HeaderColor;
Canvas.Brush.Style:=bsSolid;
Canvas.FillRect(r);
if CloseButton.IsControlVisible and (CloseButton.Parent=Self) then begin
if Align in [alLeft,alRight] then
r.Top:=CloseButton.Top+CloseButton.Height+1
else
r.Right:=CloseButton.Left-1;
end;
// caption
if Caption<>'' then begin
TxtH:=Canvas.TextHeight('ABCMgq');
TxtW:=Canvas.TextWidth(Caption);
if Align in [alLeft,alRight] then begin
// vertical
dx:=Max(0,(r.Right-r.Left-TxtH) div 2);
dy:=Max(0,(r.Bottom-r.Top-TxtW) div 2);
Canvas.Font.Orientation:=900;
Canvas.TextOut(r.Left+dx,r.Bottom-dy,Caption);
end else begin
// horizontal
dx:=Max(0,(r.Right-r.Left-TxtW) div 2);
dy:=Max(0,(r.Bottom-r.Top-TxtH) div 2);
Canvas.Font.Orientation:=0;
Canvas.TextOut(r.Left+dx,r.Top+dy,Caption);
end;
end
end;
and this is the result, as shown in the images: