Autor Beitrag
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mi 05.07.06 18:19 
Hallo.

Ich verwende DrawText() um einen Text auf einen Canvas zu zeichnen. Da ich Zeilenumbrüche korrekt formatiert haben möchte, nehme ich die Funktion DrawText dazu her:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var
  r:TRect;
begin
  r := image1.ClientRect;
  with image1.Canvas do begin
    image1.Height := DrawText(handle,PAnsiChar(edit1.Text),-1,r,DT_WORDBREAK or DT_CALCRECT );
    button1.Height := image1.Height;
    r := image1.ClientRect;
    DrawText(handle,PAnsiChar(edit1.Text),-1,r,DT_LEFT or DT_WORDBREAK );
  end;

Leider wird mir dabei der Text abgeschnitten, wie auf dem angehängten Screenshot zu erkennen ist.
Der Button an der Seite dient nur dazu, die Höhe des Images zu verdeutlichen. Wie man sehen kann, ist das Image hoch genug, nur der Text wird irgendwann einfach abgeschnitten.

Was mache ich denn falsch ?
Einloggen, um Attachments anzusehen!
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Do 06.07.06 11:54 
Hallo,

durch setzen von Image.Height verändert man nicht die größe der Zeichenfläche.
Deshalb schneidet er immer in der Höhe des Canvas ab die zur Entwicklungs-Zeit gesetzt ist.
Mit Image.Picture.Graphic.Height kann man die Höhe neu setzen.
z.B.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var
  r:TRect;
begin
  with Image1 do
    begin
    r := Rect(0,0,Width,0);//Breite vorgeben
    DrawText(Canvas.handle,PAnsiChar(edit1.Text),-1,r,DT_WORDBREAK or DT_CALCRECT );
    Picture.Graphic.Height := r.Bottom;
    DrawText(Canvas.handle,PAnsiChar(edit1.Text),-1,r,DT_LEFT or DT_WORDBREAK );
    end;

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
matze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Do 06.07.06 16:52 
vielen Dank für die schnelle und kompetente Hilfe !

Super !