Recent

Author Topic: How to add the width of the panels that is inside another panel?  (Read 75 times)

ReinaldoSergioPTBR

  • New member
  • *
  • Posts: 8
How to add the width of the panels that is inside another panel?
« Last Edit: August 12, 2019, 04:53:43 pm by ReinaldoSergioPTBR »

lucamar

  • Hero Member
  • *****
  • Posts: 1942
Re: How to add the width of the panels that is inside another panel?
« Reply #1 on: August 12, 2019, 06:41:46 pm »
Code: Pascal  [Select]
  1. function PanelsWidth(AParent: TPanel): Integer;
  2. var
  3.   i: Integer;
  4. begin
  5.   Result := 0;
  6.   for i := 0 to AParent.ControlCount-1 do
  7.     if AParent.Controls[i].InheritsFrom(TPanel) then
  8.       Result := Result + TPanel(AParent.Controls[i]).Width;
  9. end;

Depending on your needs you may want to add the lateral BorderSpacing properties, and the border and bevel widths too.
« Last Edit: August 12, 2019, 06:46:27 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.