代码之家  ›  专栏  ›  技术社区  ›  JimPapas

Delphi 11应用程序中的拆分器无法按预期工作

  •  0
  • JimPapas  · 技术社区  · 2 年前

    我有一张有两个面板和一个拆分器的表格。一个面板(面板2)右对齐,拆分器右对齐,第二个面板(窗格1)客户端对齐。 当我向左移动拆分器时,panel2的宽度会如预期的那样增加。当我将拆分器向右移动时,它会按预期减小。当我将拆分器向右移动到其minSize之外时,panel2消失,拆分器一直向右移动,panel1占据了客户端区域的所有其余部分。 我预计拆分器不会移动超过minSize,panel2将保持可见,宽度等于拆分器的minSize。 这是一个测试应用程序

    类型

    object Form17: TForm17
    Left = 0
    Top = 0
    Caption = 'Form17'
    ClientHeight = 442
    ClientWidth = 628
    Color = clBtnFace
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -12
    Font.Name = 'Segoe UI'
    Font.Style = []
    TextHeight = 15
    object Splitter1: TSplitter
     Left = 440
     Top = 0
     Height = 442
     Align = alRight
     MinSize = 150
     ExplicitLeft = 360
     ExplicitTop = 216
     ExplicitHeight = 100
    end
    object Panel1: TPanel
     Left = 0
     Top = 0
     Width = 440
     Height = 442
     Align = alClient
     Caption = 'Panel1'
     TabOrder = 0
     ExplicitLeft = 64
     ExplicitTop = 104
     ExplicitWidth = 185
     ExplicitHeight = 41
    end
    object Panel2: TPanel
     Left = 443
     Top = 0
     Width = 185
     Height = 442
     Align = alRight
     Caption = 'Panel2'
     TabOrder = 1
     ExplicitLeft = 448
     ExplicitTop = 128
     ExplicitHeight = 41
    end
    end
    

    密码

    unit Unit17;
    
    interface
    
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,         Vcl.Graphics,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls;
    
    type
      TForm17 = class(TForm)
        Panel1: TPanel;
        Panel2: TPanel;
        Splitter1: TSplitter;
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form17: TForm17;
    
    implementation
    
    {$R *.dfm}
    
    end.
    
    1 回复  |  直到 2 年前
        1
  •  3
  •   Andreas Rejbrand    2 年前

    这是按设计的。看看分流器 AutoSnap property :

    确定当使用拆分器使相邻对象小于MinSize时,是否将其大小调整为零。

    设置 自动捕捉 设置为false,以防止当用户试图使相邻对象小于MinSize时,拆分器将相邻对象的大小调整为零。什么时候 自动捕捉 如果为false,则会简单地阻止此类调整大小的尝试,从而使相邻对象的大小为MinSize。的默认值 自动捕捉 是真的。