t e m p o r a l 
 d o o r w a y 

The Simplest Drag / Dock

 

Drag and dock is not very hard in C++ Builder. And it is a very effective way to create a customizable Single Document Interface (SDI).

Before dragging off the form...
Form with panel docked
After...
Form when panel undocked   Panel when panel undocked

All of the work is done by the system with a few property settings and no code.

Here is the form as a Text DFM...

object Form1: TForm1
      Left = 8
      Top = 156
      Width = 337
      Height = 335
      Caption = 'Form1'
      Color = clBtnFace
      DockSite = True
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      OldCreateOrder = False
      PixelsPerInch = 96
      TextHeight = 13
      object DraggablePanel: TPanel
            Left = 8
            Top = 8
            Width = 113
            Height = 137
            Caption = 'DraggablePanel'
            Color = clHighlightText
            UseDockManager = False
            DragKind = dkDock
            DragMode = dmAutomatic
            TabOrder = 0
      end
end

That's it - no code, just this on the panel...

      DragKind = dkDock
      DragMode = dmAutomatic

and this...

      DockSite = True

on the form.

Copyright © 2004 by Mark Cashman (unless otherwise indicated), All Rights Reserved