Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi TLabel ½ Zeilenumbruch (https://www.delphipraxis.net/100142-tlabel-%BD-zeilenumbruch.html)

SubData 23. Sep 2007 17:49

Re: TLabel ½ Zeilenumbruch
 
Alternativ würde ich einfach mehrere Labels nehmen und diese dann "dynamisch" positionieren... ?! :)

alzaimar 24. Sep 2007 08:27

Re: TLabel ½ Zeilenumbruch
 
Liste der Anhänge anzeigen (Anzahl: 1)
Zitat:

Zitat von Balu der Bär
Ok danke, habs jetzt selbst gezeichnet.

Na ja, geht auch, Du verzichtest aber auf die schönen Formatoptionen
Zitat:

Zitat von Balu der Bär
Die RTF-Lösung war mir dann doch etwas suspekt und das Selberzeichnen anscheinend am einfachsten und schnellsten. :stupid:

Öhm, na ja.

Delphi-Quellcode:
uses RichEdit;
...
Procedure TForm1.DrawRTFLines(aText: TStrings; aGap: Integer);
Const
// Einfach aus Wordpad geklaut, hier wird aber auch der Font gesetzt.
  sRTFPreamble = '\rtf1\ansi\ansicpg1252\deff0\deflang1031{\fonttbl{\f0\fswiss\fcharset0 Arial;}}'
    + '\viewkind4\uc1\pard\f0';
  sRTFLine = '\fs20 %s\par\fs%d\par';  // /fs20 = Fontgroße 10 (wieso da 20 stehen muss, k.A.)

Var
  sRTF: String;
  i: Integer;
  sText: TStringStream;
  P: TPoint;

Begin
// RTF-Code erzeugen
  sRTF := sRTFPreamble;
  For i := 0 To aText.Count - 1 Do
    sRTF := sRTF + Format(sRTFLine, [aText[i], aGap]);

// RTF muss per Stream/File in das Control geschrieben werden
  sText := TStringStream.Create(Format('{%s}', [sRTF]));
  Try
    RichEdit.Lines.LoadFromStream(sText);
  Finally
    sText.Free;
  End;
// Höhe des gesamten textes herausbekommen
  RichEdit.Perform(EM_POSFROMCHAR, Integer(@P), Length(RichEdit.Lines.text));
// Control anpassen
  RichEdit.Height := P.Y;
End;


Alle Zeitangaben in WEZ +1. Es ist jetzt 17:01 Uhr.
Seite 2 von 2     12   

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