AGB  ·  Datenschutz  ·  Impressum  







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

Textzeilen umbrechen

Ein Thema von xaromz · begonnen am 23. Jul 2005 · letzter Beitrag vom 6. Jun 2006
Antwort Antwort
Daniel G
(Gast)

n/a Beiträge
 
#1

Re: Textzeilen umbrechen

  Alt 4. Jun 2006, 00:45
Zitat von Luckie:
Ich dachte so geht es, aber in der for-Zeile meint er, inkompatible Typen.
Na ja, ich tippe einfach mal, das liegt daran, dass du "Length" auf einen PInteger anwenden willst, oder?

//Edit:
Hilft dir das hier? Hab' ich bei Experts Exchange gefunden, müsstest natürlich noch etwas anpassen.

Delphi-Quellcode:
procedure TForm1.but_CustomTextClick(Sender: TObject);
var
TextStr: String;
Bmp1: TBitmap;
numChar, oNum, lines: Integer;
aSize: tagSize;
begin
TextStr := 'Thisisatextstringlongenoughtowrap a couple of times. And'+
           'Moretextherefollowedbevenmore text followed by eveen more text'+
           ' followed-by-even-more-text followed by even moore text';
Bmp1 := TBitmap.Create;
try
  Bmp1.Width := 188;// try to have a 3 pixel border, use 182 below
  Bmp1.Height := 230;
  Bmp1.Canvas.Font.Name := 'Arial';
  Bmp1.Canvas.Font.Size := 11;

  if Length(TextStr) < 1 then Exit;
  lines := 0;
  repeat
  GetTextExtentExPoint(Bmp1.Canvas.Handle, PChar(TextStr),Length(TextStr),182,
                     @numChar, nil, aSize);
  oNum := numChar;
  while (numChar > 1) and not
      (TextStr[numChar] in [' ','.',',','-','_','?','!','$','(',')']) do
       Dec(numChar);
  if numChar = 1 then
    numChar := oNum;
  TextOut(Bmp1.canvas.handle,3,(lines*(aSize.cy+8))+3,PChar(TextStr), numChar);
  Delete(TextStr,1,numChar);
  Inc(Lines);
  until Length(TextStr) < 1;

  Canvas.Draw(530,290, Bmp1);
  finally
  FreeAndNil(Bmp1);
  end;
end;
Quelle
  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 08:46 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