Controlling How Child Controls Are Undocked

From RAD Studio
Jump to: navigation, search

Go Up to Implementing Drag and Dock in Controls

A docking site automatically allows child controls to be undocked when they are dragged and have a DragMode property of dmAutomatic. Docking sites can respond when child controls are dragged off, and even prevent the undocking, in an OnUnDock event handler

 property OnUnDock: TUnDockEvent;
 TUnDockEvent = procedure(Sender: TObject; Client: TControl; var Allow: Boolean)   of object;
__property TUnDockEvent OnUnDock = {read=FOnUnDock, write=FOnUnDock}; 
typedef void __fastcall (__closure *TUnDockEvent)(System::TObject* Sender, TControl* Client, TWinControl* NewTarget, bool &Allow);

The Client parameter indicates the child control that is trying to undock, and the Allow parameter lets the docking site (Sender) reject the undocking. When implementing an OnUnDock event handler, it can be useful to know what other children (if any) are currently docked. This information is available in the read-only DockClients property, which is an indexed array of TControl. The number of dock clients is given by the read-only DockClientCount property.

See Also