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

 

相关文章:

  • 2022-03-07
  • 2022-12-23
  • 2022-12-23
  • 2022-01-17
  • 2022-01-20
  • 2021-07-19
猜你喜欢
  • 2022-12-23
  • 2021-11-09
  • 2021-09-20
  • 2022-12-23
  • 2021-06-01
  • 2022-12-23
  • 2021-04-12
相关资源
相似解决方案