Board index » delphi » Dock : Is it possible to manually dock...

Dock : Is it possible to manually dock...

Hi, I have 4 identical forms that I want to dock on another form.  I want to
dock them at the start of the prog. ( in the create) and when a form is
closed (when it is undocked).  So I've put some code in the closeQuery of
the form and I call close at the creation.

But the 4 forms are docked vertically (||||) and I want them to be 4 squares
(::). Here is my code :

procedure TFormTerm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
// PageIndex is a property of the form between 1 - 4.
  var
   rect : TRect;
  OffsetX, OffsetY : integer;
  DockType : TAlign;
begin
     if (HostDockSite is TConjointHost) then
      TConjointHost(HostDockSite).UpdateCaption;
    OffsetX := PageIndex mod 2;
    OffsetY := PageIndex div 2;

    rect.Left :=  (OffsetX * Self.Width) div 2;
    rect.Right := ((OffsetX + 1) * Self.Width) div 2;
    rect.bottom := ((OffsetY + 1) * Self.Height) div 2;
    rect.top := (OffsetY * Self.Height) div 2;
    BoundsRect := Self.BoundsRect;

  Self.ManualDock(mainform.ConjointHost, nil, alTop);
// another thing I tried but didn't worked.
{    Case PageIndex of
      0 : DockType := alTop;
      1 : DockType := alRight;
      2 : DockType := alBottom;
      3 : DockType := alRight;
    end;
    Self.ManualDock(mainform.ConjointHost, nil, DockType);}
    CanClose := false;
 end;

Can somebody tell me if there's a better way ( a way that will work!!) or
some hints.

Thanks,
Christian Lavalle.

 

Re:Dock : Is it possible to manually dock...


Hi,
   if you examine the DockEx example, the Dock windows use this code to dock
into a TConjoinHost window:

Host := TConjoinDockHost.Create(Application);
Host.BoundsRect := Self.BoundsRect;
Self.ManualDock(Host, nil, alNone);
Self.DockSite := False;
Message.DockSource.Control.ManualDock(Host, nil, DockType);
 TDockableForm(Message.DockSource.Control).DockSite := False;
 Host.Visible := True;

where Host is an instance of TConjoinDockHost and
Self is a TDockHost and
Message.DockSource.Control is also a TDockHost...

Seems to work here...

Other Threads