Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Splitter in Delphi 11 application does not work as expected

I have a form with two panels and a splitter. One panel (panel2) is right-aligned, the splitter is right-aligned, and the second panel (panel1) is client-aligned.
When I move the splitter to the left, the width of panel2 increases as expected. When I move the splitter to the right it decreases as expected. When I move the splitter further right than its minSize, then panel2 disappears, the splitter goes all the way to the right, and panel1 takes up all the rest of the client area.
I expected that the splitter would not move beyond minSize and panel2 would remain visible with a width equal to the minSize of the splitter.
Here is a test application

Form

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

code

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

>Solution :

This is as designed. Have a look at the splitter’s AutoSnap property:

Determines whether neighboring objects are resized to zero when the splitter is used to make them smaller than MinSize.

Set AutoSnap to false to prevent the splitter from resizing neighboring objects to zero when the user tries to make them smaller than MinSize. When AutoSnap is false, such resize attempts are simply blocked, leaving the neighboring object with a size of MinSize. The default value of AutoSnap is true.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading