Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I do Drag and Dock like the Delphi IDE with pins and tabs?

I would like to make Drag and Dock work as well in my applications as it does in the Delphi IDE (i.e. being able to drag around the Object Inspector / Structure View and Dock them at suitable sites). I've had pretty good success with docking forms into a PageControl, but was wondering if anyone knows how to get it to work with the the little close buttons and pins and so on.

I'd also be interested to know what components the Delphi IDE uses to achieve this.

The reason for my question is I want to make much more advanced videos on how to do this, the two that I have done previously are here and here.

like image 358
Alister Avatar asked Feb 16 '12 22:02

Alister


1 Answers

You can use JVCL JvDocking components to drag and dock, in almost any version of Delphi. It's free and open source. The style with pins and close buttons is available using a docking style called the VID (visual interdev) style, that comes with JvDocking.

enter image description here

There are already a bunch of commercial alternatives also, and there is some support built into Delphi, which I find insufficient for my needs. While the Delphi IDE has its own internal docking library, tab support is very limited, slow, and in my subjective opinion, broken.

However, even on ancient delphi versions, Delphi 7 and up, JvDocking, provides all the functionality that the VCL's docking provides, plus more, so there's no problem ignoring the built in VCL functionality, which is to docking as TStringGrid is to real Grids.

Steps with JvDocking:

  1. Drop dock server and dock style object on main (host form) and connect them.
  2. Drop dock client component on the client (form to be docked) and connect it to the dockstyle.
  3. Configure properties of dock server.
  4. Run app. Have it create a form. Now drag the client form to an area that is made dockable by the dock server. Watch it dock nicely.

For docking in code demos see the JvDocking demos in the JVCL Examples folder.

Update

Or you can use what is built into the Delphi VCL since XE and XE2. XE and XE2 include a docking demo project named dockex.dpr.

On Win7/Vista the demo is located at:

C:\Users\Public\Documents\RAD Studio\9.0\Samples\Delphi\VCL\Docking

Look here for the demo on Win XP:

C:\Documents and Settings\All Users\Documents\RAD Studio\9.0\Samples\Delphi\VCL\Docking

You should also check out the documentation for TDockTabSet in the VCL, and the EDN article linked in the comments, which has source code you can download here. In my humble opinion, the Jedi JvDocking stuff is more professional and slick than the Docking Demo that ships with Delphi, but the built in stuff has the advantage of working without installing anything additional. I just tried the DockTabSet demo and the built in docking demos, and they are slow, and the painting is ugly and flickers. JvDocking looks professional. It's your call.

like image 144
Warren P Avatar answered Nov 10 '22 01:11

Warren P