📄 mainfm.pas
字号:
newDocFm:TDocForm;
besideForm:TWinControl;
WinControls:TList;
// dockClient:TJvDockClient;
n : Integer;
begin
Assert(Assigned(DockServer.DockStyle));
newDocFm := MakeNewDocFm;
newDocFm.Show;
Assert(Assigned(DockServer.CustomDockPanel));
// TJvDockClient.CreateTabHostAndDockControl
{ newDocFm.DockClient.CreateTabHostAndDockControl(
ParentForm, Source.Control
)
}
// Depending on how much stuff is on the form, we could
// dock in a different location:
WinControls := TList.Create;
try
DockServer.CustomDockPanel.GetDockedControls(WinControls);
n := WinControls.Count;
Trace('before New Document Window docked, Docked Clients='+IntToStr(n));
{ Simplest version just puts siblings side by side horizontally: }
// newDocFm.ManualDock( DockServer.CustomDockPanel, nil, alNone )
(* A nicer way to lay things out, a "drill down" viewing method
suitable for a wide top level document, and a bunch of smaller
panels below it: *)
{ here is how we decide how to position the documents when they are docked }
if n = 0 then begin { first entry }
Trace('docking first form which should take up entire custom dock area ');
newDocFm.ManualDock( DockServer.CustomDockPanel, nil, alNone )
end else if n = 1 then begin {second entry }
Trace('docking second form which should be docked below the first form');
newDocFm.ManualDock( DockServer.CustomDockPanel, TWinControl(WinControls.Items[0]) , alBottom )
end else if n >= 2 then begin { third and later entries! }
// There is a problem in this case! Debugging it!
Trace('docking additional form which should be docked beside the last form');
besideForm := TWinControl(WinControls.Items[n-1]);
newDocFm.ManualDock( DockServer.CustomDockPanel, besideForm, alRight );
end;
finally
WinControls.Free;
end;
end;
procedure TMainForm.FormCreate(Sender: TObject);
begin
SetLengtH( FColors, 5 );
FColors[0] := $00F9CAD9;
FColors[1] := $00C8F7FB;
FColors[2] := $00CBDDF8;
FColors[3] := $00DBFBE8;
FColors[4] := $00FDEFD9;
DockIniStorage.FileName := ExtractFilePath(Application.ExeName)+'CustomTabbedDockingLayout.ini';
end;
procedure TMainForm.dockServerFinishSetDockPanelSize(
DockPanel: TJvDockPanel);
begin
Trace('OnFinishSetDockPanelSize panel='+DockPanel.Name)
end;
procedure TMainForm.dockServerGetClientAlignSize(Align: TAlign;
var Value: Integer);
var
s:String;
begin
case Align of
alNone:
s := 'None';
alTop:
s := 'Top';
alBottom:
s := 'Bottom';
alLeft:
s := 'Left';
alRight:
s := 'Right';
alClient:
s := 'Client';
alCustom:
s := 'Custom';
end;
Trace('OnGetClientAlignSize '+s);
end;
procedure TMainForm.Button2Click(Sender: TObject);
var
t,n:Integer;
ctrl :TWinControl;
s:String;
strs:TStringLIst;
tree:TJvDockAdvTree;
WinControls:TList;
begin
{$ifdef JVDOCK_DEBUG}
// if you build the JvDock packages with the $define JVDOCK_DEBUG,
// you can do XML dumps of the entire ADVTree, which is helpful when
// you're debugging.
Trace('--- DebugDump starts ---');
strs := TStringList.Create;
try
tree := TJvDockAdvPanel( DockServer.CustomDockPanel ).ADVTree;
tree.Debug('CustomDockPanel.ADVTree',Strs);
for t := 0 to strs.Count-1 do begin
Trace(strs[t]);
end;
finally
strs.Free;
end;
Trace('--- DebugDump ends ---');
{$endif}
{
Note that every VCL Control already has a basic set of docking information
properties:
TControl.DockClientCount - number of things docked directly onto this control.
TControl.DockClient[x] - get the actual docked objects.
DockServer.<XYZ>DockPanel.GetDockedControls gets you access not only to
directly docked Dock Client forms, but also gets you anything nested
inside a set of tabbed-pages, etc. This gives you a simple FLAT
way to find out what is docked. If you need to know the hierachy stuff,
you need to go in and write lots of code, use GetDockedControls as your
template, and good luck.
}
Trace('--- Introspection starts ---');
WinControls := TList.Create;
try
DockServer.CustomDockPanel.GetDockedControls(WinControls);
n := WinControls.Count; // WinControls contains pointers to TWinControls.
Trace('Docked Client Count='+IntToStr(n));
for t := 0 to n-1 do begin
ctrl := TWinControl(WInControls.Items[t]);
if Assigned(ctrl) then
s := ctrl.Name
else
s := '<nil>';
Trace('WinControls['+intToStr(t)+']='+s );
end;
Trace('--- finished. ---');
finally
WinControls.Free;
end;
end;
procedure TMainForm.Button3Click(Sender: TObject);
begin
SaveDockTreeToAppStorage( DockIniStorage, 'DockingLayout' );
end;
procedure TMainForm.Button4Click(Sender: TObject);
begin
LoadDockTreeFromAppStorage(DockIniStorage, 'DockingLayout' );
end;
procedure TMainForm.ButtonCreateTabDockClick(Sender: TObject);
var
newDocFm1,newDocFm2:TDocForm;
// n : Integer;
tabHost: TJvDockTabHostForm;
begin
newDocFm1 := MakeNewDocFm;
newDocFm2 := MakeNewDocFm;
tabHost := ManualTabDock( DockServer.CustomDockPanel, newDocFm1, newDocFm2 );
// How to add a 3rd and a fourth page:
newDocFm2 := MakeNewDocFm;
ManualTabDockAddPage( tabHost, newDocFm2 );
end;
procedure TMainForm.ButtonCreateConjoinClick(Sender: TObject);
var
newDocFm1,newDocFm2:TDocForm;
// conjoinHost:TJvDockConjoinHostForm;
begin
newDocFm1 := MakeNewDocFm;
newDocFm2 := MakeNewDocFm;
{conjoinHost := }ManualConjoinDock( DockServer.CustomDockPanel, newDocFm1, newDocFm2 );
// How to add a 3rd and a fourth page:
// newDocFm2 := MakeNewDocFm;
// ManualConjoinDockAdd( conjoinHost, newDocFm2 ); //TODO! IMPLEMENT THIS HELPER FUNCTION!
end;
procedure TMainForm.SpinEdit1Change(Sender: TObject);
begin
JvDockVIDStyle1.ConjoinServerOption.GrabbersSize := SpinEdit1.Value;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -