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

Retrieving the number of breaks in a FLowLayout

I want to programatically retrieve the number of breaks/newlines in a TFlowLayout.

I have a simple TFlowLayout with 4 regular controls inside (The TFlowLayout does not contain any TFlowLayoutBreak controls).

Depending on the width of the layout it looks like:

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

// * = control

// Scenario #1: No breaks
* * * *

// Scenario #2: 1 break
* * * 
*

// Scenario #3: 2 breaks
* * 
* * 

// Scenario #4: 3 breaks
*
*
*
*

Is it possible to retrieve the number of breaks of a TFlowLayout programatically or can I only go off the width of the layout to determine the number of breaks?

>Solution :

Counting the changes in Y values for the controls looks to work since the array is in layout order.

procedure TForm1.Button1Click(Sender: TObject);
var
  Cnt, I : integer;
begin
  if FlowLayout1.ControlsCount = 0 then Cnt := 0 else Cnt := 1;
  for I := 1 to FlowLayout1.ControlsCount - 1 do
    if FlowLayout1.Controls[I-1].Position.Y <> FlowLayout1.Controls[I].Position.Y then inc(cnt);
  button1.Text := IntToStr(Cnt);
end;
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