Einzelnen Beitrag anzeigen

Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#15

AW: Panelreheinfolge einhalten.

  Alt 3. Aug 2016, 21:19
Delphi-Quellcode:
unit Unit2;

interface

uses
  Vcl.Controls;

procedure ReAlignChildControls( AParentControl: TWinControl );

implementation

uses
  System.Types;

procedure ReAlignChildControls( AParentControl: TWinControl );
var
  lIdx : Integer;
  lBounds : TRect;
  lControl: TControl;
begin
  lBounds := AParentControl.ClientRect;

  for lIdx := 0 to AParentControl.ControlCount - 1 do
    begin
      lControl := AParentControl.Controls[ lIdx ];

      if not lControl.Visible
      then
        Continue;

      case lControl.Align of
        alTop:
          begin
            lControl.Top := lBounds.Top;
            lBounds.Inflate( 0, -lControl.Height, 0, 0 );
          end;
        alBottom:
          begin
            lControl.Top := lBounds.Bottom - lControl.Height;
            lBounds.Inflate( 0, 0, 0, -lControl.Height );
          end;
        alLeft:
          begin
            lControl.Left := lBounds.Left;
            lBounds.Inflate( -lControl.Width, 0, 0, 0 );
          end;
        alRight:
          begin
            lControl.Left := lBounds.Right - lControl.Width;
            lBounds.Inflate( 0, 0, -lControl.Width, 0 );
          end;
      end;
    end;
end;

end.
Die Ausrichtung erfolgt anhand der Z-Order (kann man über TControl.BringToFront oder TControl.SendToBack beeinflussen).
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
  Mit Zitat antworten Zitat