这在 Delphi 停靠中可能吗?还是需要自定义拖放?

Is this possible in Delphi Docking or does it need custom Drag and Drop?

请参考下图:

我的问题:我能否控制停靠预览矩形和最终停靠矩形,以便停靠面板保持其高度并占据右侧面板的整个宽度?换句话说,我可以创建一个管理单元类型的效果,在对接第一个面板时,它以自己的高度位于右侧面板的顶部。那么第二个面板在停靠时会以自己的高度卡入其下方?

我怀疑我需要使用我自己的拖放而不是停靠来进行那种拖放捕捉到位。我想使用 Docking,因为它有很好的目标预览矩形功能,为此我必须在拖放中编写自己的代码。

这是一个你可以实现的例子

procedure TForm3.ScrollBox1DockDrop(Sender: TObject; Source: TDragDockObject; X,
  Y: Integer);
begin
  //Change the dropped component (source) Align property to alTop to achieve top 
  //alignment of docked control
  Source.Control.Align := alTop;
end;

procedure TForm3.ScrollBox1UnDock(Sender: TObject; Client: TControl;
  NewTarget: TWinControl; var Allow: Boolean);
begin
  //Reset Align property to alNone to revert undocked control to original size
  //NOTE: Changing Source.DocRect like in OnDockOver event below will also change
  //original size of the control. So when undocked it will no longer have same 
  //dimensions as it did before docking 

  Client.Align := alNone;
end;

//Here we can manipulate the size of DockRect to get better preview of docked component.
//NOTE: Changing Source.DocRect like in OnDockOver event below will also change
//original size of the control. So when undocked it will no longer have same 
//dimensions as it did before docking
procedure TForm3.ScrollBox1DockOver(Sender: TObject; Source: TDragDockObject; X,
  Y: Integer; State: TDragState; var Accept: Boolean);
var
  ARect: TRect;
begin
  Accept := Source.Control is TPanel;
  if Accept then
  begin
    ARect.TopLeft := (Sender as TScrollBox).ClientToScreen(Point(0,Y));
    ARect.BottomRight := (Sender as TScrollBox).ClientToScreen(Point((Sender as TScrollBox).ClientWidth, Source.Control.Height+Y));
    Source.DockRect := ARect;
  end;
end;

您可能还想查看此问题以获取有关对接的更多信息,包括对某些第三方组件的建议

How do I make dockable forms like the IDE's without the very slow freezing movement of the dockable form?