This sample demonstrates how to implement docking windows.
You can find the Docking sample project at:
- Start > Programs > Embarcadero RAD Studio > Samples and then navigate to either:
- Subversion Repository for Delphi: http://sourceforge.net/p/radstudiodemos/code/HEAD/tree/branches/RadStudio_XE4/Delphi/VCL/Docking/
- Subversion Repository for C++: http://sourceforge.net/p/radstudiodemos/code/HEAD/tree/branches/RadStudio_XE4/CPP/VCL/Docking/
The application creates a main form with two dockable toolbars. The main form provides buttons to open new dockable forms of different colors. These forms can be docked on the main form or on each other, either in parallel (conjoin docking) or as separate tabs (tab docking).
How to Use the Sample
- Navigate to Start > Programs > Embarcadero RAD Studio > Samples and open dockex.dproj.
- Press F9 or choose Run > Run.
The project contains four source files:
The class for the form that hosts clients docked in parallel.
The class for a dockable form.
The class for the main form.
The class for the form that hosts clients docked as separate tabs.
- TConjoinDockHost implements a form host on which two or more forms are docked in parallel. It implements handlers for the basic docking events: OnDockDrop, OnDockOver, OnGetSiteInfo, OnUnDock.
- TDockableForm implements a form that can be docked. It is the class responsible of creating the host form, conjoin or tab, depending on the mouse position.
- TTabDockHost implements a form host where two or more forms are docked as separate tabs.
- TMainForm, the main form, contains two dockable toolbars and a menu bar. The toolbars provide buttons that open new dockable forms of different colors. TMainForm also handles the docking of forms on itself.
- When a TDockableForm is being docked, a host form is created. The host can provide either tab docking, if the form being docked is aligned at its center, or conjoin docking, if the form being docked is aligned at the top, bottom, left, or right of the host form.
- The TControl.UndockWidth and TControl.UndockHeight properties are used to restore the original size of the control, when undocked.
- Conjoin docking and tab docking hosts self-destruct when the penultimate form gets undocked.
- To preview the dock area where a control is going to be docked, set the DockRect property of TDragDockObject.