8

I have this type of situation (see image), now when I move Splitter1 up in run-time, Panel2 height grows and also Form1 height grows.

But I need to know and block this type of event, when Splitter1 can't be moved up because of Panel1.Constraints.MinHeight is reached, so Panel2 can't be changed of it's height and Form1 too.

Thanks for any help.

preview

-- Edit --
Panel1.Align := alLeft;
Splitter1.Align := alBottom;
Panel2.Align := alBottom;

NevTon
  • 265
  • 3
  • 15

2 Answers2

7

You can check and deny further sizing in splitter's CanResize event.

procedure TForm1.Splitter1CanResize(Sender: TObject; var NewSize: Integer;
  var Accept: Boolean);
begin
  Accept := ClientHeight - (NewSize + Splitter1.Height) >= Panel1.Constraints.MinHeight;
end;
Sertac Akyuz
  • 54,131
  • 4
  • 102
  • 169
1

Set the Splitter AutoSnap property to false and its MinSize property to the MinHeight of Panel1.

Uwe Raabe
  • 45,288
  • 3
  • 82
  • 130
  • I have `AutoSnap` set to False, and `ResizeStyle` set to rsUpdate. I'm sorry for not mentioning of this until now. – NevTon Nov 01 '13 at 22:35
  • Then you seem to have missed to set the MinSize of the Splitter to the MinHeight of Panel1. Without that my solution will not work. Anyway, Sertac showed another valid approach. – Uwe Raabe Nov 02 '13 at 00:27
  • No, I don't missed `Splitter1.MinSize` property. It is set to 84, this will be the min size of `Panel2` when moving `Splitter1` down. – NevTon Nov 02 '13 at 01:41
  • 1
    Well, the trick is to set it to the MinHeight of Panel1 (i.e. 200). It may not be what is desired, but it is a workaround for that weird bug/feature in the TSplitter implementation. TSplitter.MinSize is checked for both ends. Sertacs solution is more flexible, though. – Uwe Raabe Nov 02 '13 at 07:54
  • @UweRaabe - I find it also more reliable :) because if you change the Constraints of the panel then you have to REMEMBER to update also the MinSize property of the splitter. (Hey! My Firefox spellchecker says that 'splitter' is not a valid english word!) – Gabriel Aug 13 '18 at 10:26