TPairSplitter: Detecting move of middle separator lazarus / 31-LCL ---------------------------------------------------------------------- Milsa · 2020-10-04 14:30 How can I detect change property "Position" by user event? ---------------------------------------------------------------------- Blaazen · 2020-10-04 14:41 Event PairSplitterSide1.Resize; (or ...Side2) ---------------------------------------------------------------------- Milsa · 2020-10-04 15:11 Thank you. I looked at main TPairSplitter. It is all problem. ---------------------------------------------------------------------- Handoko · 2020-10-04 15:21 I just tested it and understand what you meant. I think you should submit a feature request: TPairSplitter.OnPositionChanged event. ---------------------------------------------------------------------- wp · 2020-10-04 16:54 I don't understand what's wrong with Blaazen's answer, except for the typo that the even is called OnResize (not Resize). ---------------------------------------------------------------------- Handoko · 2020-10-04 16:59 The OnResize will be triggered even a single pixel movement. I believe OnAfterResized is more suitable to what OP wants. For example try to this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.PairSplitterSide1Resize(Sender: TObject);begin  ShowMessage('test');end; Then you will know it is unusable. ---------------------------------------------------------------------- wp · 2020-10-04 18:01 The OP needs an event to detect a change in the Position property of the PairSplitter. I still don't see why the PairSplitterSide's OnResize is not usable for this purpose. Look at attached demo. ---------------------------------------------------------------------- Handoko · 2020-10-04 18:10 If I want to use ShowMessage not Memo1: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.PairSplitterSide1Resize(Sender: TObject);begin//  Memo1.Lines.Add('Side 1: PairSplitter.Position = ' + IntToStr(PairSplitter1.Position));  ShowMessage(PairSplitter1.Position.ToString);end; How to make the event only triggered when the mouse click released (mouse up) ? For comparison try my code, which use TSplitter: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Dialogs, ExtCtrls; type   { TForm1 }   TForm1 = class(TForm)    Panel1: TPanel;    Splitter1: TSplitter;    procedure Splitter1Moved(Sender: TObject);  end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Splitter1Moved(Sender: TObject);begin  ShowMessage(Panel1.Width.ToString);end; end. If you wonder why I insist not triggered on every single pixel movement. Here the example cases: If user change the setting, I want to save it to disk. If you use Firefox you will know there is no "Apply" nor "OK" nor "Save" button on user preference form. Many modern programs behave so. Or if user slide the handle, I need to do screen refresh that require some heavy calculations. ---------------------------------------------------------------------- wp · 2020-10-04 22:30 You will have same issues with every OnResize event of any other control supporting it (TForm, TPanel, TGroupBox, TStringGrid etc). One possibility to avoid seeng the event multiple times during the dragging action of the splitter is to add a timer: the timer must be disabled initially and be set to some acceptable interval (some 100 ms). On the OnResize event of the PairSplitter or the other controls mentioned you enable the timer. In the OnTimer event of the timer you disable the timer again and execute the code that you would like to be executed in the OnResize event. Now when you drag the splitter the OnResize events are fired in short intervals, shorter than the timer's interval, constantly resetting the timer. Only when the resizing operation stops (or when you stop moving the mouse but still keep the button down  -- that's a disadvantage...) the OnTimer event occurs. ---------------------------------------------------------------------- jamie · 2020-10-05 01:20 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Splitter2ChangeBounds(Sender: TObject);begin   If Splitter2.MouseEntered then Beep;end; procedure TForm1.Splitter2Moved(Sender: TObject);begin  if Splitter2.MouseEntered Then Beep;end;                                       take your pick.. Bounds Change calls always as you are dragging it. Moved only calls when done but the mouse enter will register on both.. This control uses the TWinControl so it has more functionality than this.. I suppose an event can be added  "OnUserMove(Sender:Tobject; aFlag=(Moving, Released)); etc.. ---------------------------------------------------------------------- Milsa · 2020-10-06 15:43 Quote from: Handoko on October 04, 2020, 05:21:17 pmI just tested it and understand what you meant. I think you should submit a feature request: TPairSplitter.OnPositionChanged event. Yes, it is problem. I have collision with main PairSplitter.OnResize. I have application with TPairSplitter. (TPS). If I change window size, I want change TPS by window size. I change Position too by percent of TPS height. Percent of Position of height I change in TPS- Side1.OnResize. But percent of height is changed when I change the main application window size (MAWS). How can I will create this code? - change MAWS changes all TPS proportional with Position ---------------------------------------------------------------------- Milsa · 2020-10-06 15:46 I will prepare a test application. ---------------------------------------------------------------------- wp · 2020-10-06 16:40 Quote from: Milsa on October 06, 2020, 05:43:47 pmI change Position too by percent of TPS height. Percent of Position of height I change in TPS-Side1.OnResize. But percent of height is changed when I change the main application window size (MAWS). How can I will create this code? - change MAWS changes all TPS proportional with Position I think (not tested...) this is possible by simulating some kind of OnMoved event for the PairSplitter based on its OnMouseDown/Move/Up events, and leave the sides' OnResize alone. The splitter's OnResize, then, should reposition the splitter according to its relative position within the form. I guess it's not difficult but will require some code... Alternatively you could use a standard TSplitter with two panels above and below the splitter. Set the splitter's Align to alNone so that it is floating. Use the anchor editor to attach the upper panel to the top, left and right sides of the form; its bottom side should be attached to the top side of the splitter. The lower panel should be attached to the left, bottom and right sides of the form, and the upper edge should be attached to the lower side of the splitter. The splitter should be anchored to the left and right sides of the form, but -- and this is important -- it must be  floating vertically, i.e. the anchor editor must not show checks for "top anchoring" and "bottom anchoring". In this configuration, the splitter will move when the size of the form changes, and its speed of movement depends on the relative position of the splitter inside the form. Have a look at the attached sample. ---------------------------------------------------------------------- Milsa · 2020-10-06 17:13 Testing app in attachment. My idea: - resize main window => proportional change TPSs sizes and Positions - change Position => no change (but change top of second StringGrid) but ratio calculation for main window resize ---------------------------------------------------------------------- wp · 2020-10-06 17:39 I attempt to bend my brain in order to fix your solution because it took me only a few minutes to set up a solution with TSplitter and anchoring. ---------------------------------------------------------------------- Milsa · 2020-10-06 18:16 I meant TPairSplitter is better than TSplitter but your solution is excellent. Thank you for your help. ---------------------------------------------------------------------- Milsa · 2020-10-06 18:20 I have to study anchoring. ---------------------------------------------------------------------- wp · 2020-10-06 18:58 Quote from: Milsa on October 06, 2020, 08:20:52 pmI have to study anchoring. https://wiki.freepascal.org/Autosize_/_Layout https://wiki.freepascal.org/Anchor_Sides