Docking (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following example is taken from the docking demo. It shows how the OnUnDock event handler of the conjoinment docking site re-enables docking in the control that is undocked (if it is a dockable form). In addition, when the next-to-last docked control is undocked, the conjoinment docking site sends itself a close message so that the last docked control is undocked to its old position and size.

Code

void __fastcall TConjoinDockHost::FormUnDock(TObject *Sender, TControl *Client,
      TWinControl *NewTarget, bool &Allow)
{
  // Only two dock clients means the host must be destroyed and
  // the remaining window--undocked to its old position and size.
  // Recall that OnUnDock gets called before the undocking
  // actually occurs.
  if (Client->ClassNameIs("TDockableForm"))
	dynamic_cast<TDockableForm *>(Client)->DockSite = True;
  if ((DockClientCount == 2) && (NewTarget != this))        // Self?
	PostMessage(dynamic_cast<TConjoinDockHost *>(this)->Handle, WM_CLOSE, 0, 0);
  UpdateCaption(Client);
}

Uses