AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

TAlignLayout.Top die Reihenfolge stimmt nicht

Ein Thema von Peter-Pascal · begonnen am 4. Aug 2019 · letzter Beitrag vom 5. Aug 2019
Antwort Antwort
Benutzerbild von Gausi
Gausi
Online

Registriert seit: 17. Jul 2005
910 Beiträge
 
Delphi 12 Athens
 
#1

AW: TAlignLayout.Top die Reihenfolge stimmt nicht

  Alt 4. Aug 2019, 19:36
Äh, nein. Eher so:

Delphi-Quellcode:
  ScrollBox1.BeginUpdate;
  rec := TRectangle.Create(bfDeckblattForm);
  ScrollBox1.AddObject(rec);
  rec.Parent := ScrollBox1;
  // ---------
  rec.Top := 42; // oder was sehr, sehr hohes,
                  // oder besser direkt der Wert, an dem es erscheinen sollte
  // -----------
  rec.Align := TAlignLayout.Top;
Being smart will count for nothing if you don't make the world better. You have to use your smarts to count for something, to serve life, not death.
  Mit Zitat antworten Zitat
hoika

Registriert seit: 5. Jul 2006
Ort: Magdeburg
8.277 Beiträge
 
Delphi 10.4 Sydney
 
#2

AW: TAlignLayout.Top die Reihenfolge stimmt nicht

  Alt 4. Aug 2019, 22:23
Hallo,
das mit dem Align war schon immer so ...

Du musst alle Elemente unsichtbar machen.
Und danach wieder alle in der richtigen Reihenfolge sichtbar machen.

Die Erstell-Reihenfolge wurde noch nie berücksictigt.
Heiko

Geändert von hoika ( 5. Aug 2019 um 06:41 Uhr)
  Mit Zitat antworten Zitat
Peter-Pascal

Registriert seit: 18. Feb 2007
Ort: 32139 Spenge
200 Beiträge
 
Delphi 11 Alexandria
 
#3

AW: TAlignLayout.Top die Reihenfolge stimmt nicht

  Alt 5. Aug 2019, 08:42
Hallo es funktioniert:

Delphi-Quellcode:
  ScrollBox1.BeginUpdate;
  rec := TRectangle.Create(bfDeckblattForm);
  ScrollBox1.AddObject(rec);
  rec.Parent := ScrollBox1;
// rec.Align := TAlignLayout.Bottom;
  rec.Align := TAlignLayout.None;
  rec.Position.Y := 1000;
  rec.Align := TAlignLayout.Top;
Ich habe den Position.y Wert hochgesetzt und es sieht so aus wie ich es gerne hätte (siehe Anhang).
Als nächstes werde ich den Tipp mit den visible := false ausprobieren.

Danke für die Hilfe.

Gruß Pascal
Angehängte Grafiken
Dateityp: jpg Aling Top korrekte Reihenfolge.jpg (11,6 KB, 8x aufgerufen)
Peter Niemeier
  Mit Zitat antworten Zitat
Schokohase
(Gast)

n/a Beiträge
 
#4

AW: TAlignLayout.Top die Reihenfolge stimmt nicht

  Alt 5. Aug 2019, 10:17
Also für die VCL hätte ich so etwas
Delphi-Quellcode:
unit AlignChildren.Vcl;

interface

uses
  System.Types,
  Vcl.Controls;

type
  WinControlHelper = class helper for TWinControl
  public
    procedure AlignChildren(ARecursive: Boolean = false);
  end;

implementation

{ WinControlHelper }

procedure WinControlHelper.AlignChildren(ARecursive: Boolean);
var
  remainingArea: TRect;
  childControlIndex: Integer;
  currentControl: TControl;

  newTop, newLeft: Integer;
  reduce: Integer;
begin
  remainingArea := Self.ClientRect;
  remainingArea.Inflate(-Padding.Left, -Padding.Top, -Padding.Right, -Padding.Bottom);

  for childControlIndex := 0 to Self.ControlCount - 1 do
  begin
    currentControl := Self.Controls[childControlIndex];

    if not currentControl.Visible then
      Continue;

    newLeft := currentControl.Left;
    newTop := currentControl.Top;

    case currentControl.Align of
      alTop:
        begin
          newTop := remainingArea.Top;
          if currentControl.AlignWithMargins then
            Inc(newTop, -currentControl.Margins.Top);

          reduce := currentControl.Height;
          if currentControl.AlignWithMargins then
            Inc(reduce, currentControl.Margins.Top + currentControl.Margins.Bottom);

          remainingArea.Inflate(0, -reduce, 0, 0);
        end;
      alBottom:
        begin
          newTop := remainingArea.Bottom - currentControl.Height;
          if currentControl.AlignWithMargins then
            Inc(newTop, -currentControl.Margins.Bottom);

          reduce := currentControl.Height;
          if currentControl.AlignWithMargins then
            Inc(reduce, currentControl.Margins.Top + currentControl.Margins.Bottom);

          remainingArea.Inflate(0, 0, 0, -reduce);
        end;
      alLeft:
        begin
          newLeft := remainingArea.Left;
          if currentControl.AlignWithMargins then
            Inc(newLeft, -currentControl.Margins.Left);

          reduce := currentControl.Width;
          if currentControl.AlignWithMargins then
            Inc(reduce, currentControl.Margins.Left + currentControl.Margins.Right);

          remainingArea.Inflate(-reduce, 0, 0, 0);
        end;
      alRight:
        begin
          newLeft := remainingArea.Right - currentControl.Width;
          if currentControl.AlignWithMargins then
            Inc(newLeft, -currentControl.Margins.Right);

          reduce := currentControl.Width;
          if currentControl.AlignWithMargins then
            Inc(reduce, currentControl.Margins.Left + currentControl.Margins.Right);

          remainingArea.Inflate(0, 0, -reduce, 0);
        end;
    end;

    currentControl.Left := newLeft;
    currentControl.Top := newTop;

    if ARecursive and (currentControl is TWinControl) then
      TWinControl(currentControl).AlignChildren(ARecursive);
  end;
end;

end.
Das müsste für FMX ähnlich funktionieren. Dort gibt es allerdings mehr Alignment-Arten die man berücksichtigen muss. Das Prinzip ist aber gleich.

Geändert von Schokohase ( 5. Aug 2019 um 10:32 Uhr)
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:43 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz