delphi控件的停靠

把一个窗体或者控件变成可以停靠只需要两步:

(1)把DragKind特性设置为dkDock。

(2)把DragMode特性设置为dmAutomatic。

另外,TPanel控件有一个UseDockManager特性,如果为Ture,它的作用是将停靠在上面的控件的尺寸扩充为Panel的大小,即充满全部Panel空间。

演示代码:

新建一个VCL form工程,加入界面代码:

object Form1: TForm1
  Left = 0
  Top = 0
  Caption = #25511#20214#20572#38752' '#29482#24735#33021
  ClientHeight = 293
  ClientWidth = 347
  Color = clBtnFace
  DockSite = True
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Shape1: TShape
    Left = 208
    Top = 48
    Width = 105
    Height = 97
    DragKind = dkDock
    DragMode = dmAutomatic
  end
  object Shape2: TShape
    Left = 208
    Top = 160
    Width = 121
    Height = 41
    DragKind = dkDock
    DragMode = dmAutomatic
  end
  object Panel1: TPanel
    Left = 25
    Top = 24
    Width = 161
    Height = 225
    Caption = 'Panel1'
    DockSite = True
    TabOrder = 0
  end
end

原文地址:https://www.cnblogs.com/hackpig/p/1668660.html