Einzelnen Beitrag anzeigen

teebee

Registriert seit: 17. Jan 2003
Ort: Köln
460 Beiträge
 
Delphi 6 Professional
 
#9

Re: TLabel: Wieso verschindet der Text?

  Alt 2. Apr 2005, 14:41
Hab auf die Schnelle was gebastelt:
Delphi-Quellcode:
unit main;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, extctrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    PaintBox1: TPaintBox;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure PaintBox1Paint(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    Txt: String;
    Procedure PaintTxt;
end;

var
  Form1: TForm1;

implementation

{$R *.DFM}


procedure TForm1.Button1Click(Sender: TObject);
begin
 Txt := Txt+#13#10+Edit1.Text;
 Label1.Caption := Txt;
 PaintTxt;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 Txt := 'Test';
end;

Procedure TForm1.PaintTxt;
Var TxtRect: TRect;
    pbRect: TRect;
Begin
 pbRect := PaintBox1.ClientRect;
 TxtRect := pbRect;
 DrawText(PaintBox1.Canvas.Handle,PChar(Txt),Length(Txt),TxtRect,DT_CALCRECT);
 TxtRect.Top := pbRect.Bottom-TxtRect.Bottom;
 TxtRect.Bottom := pbRect.Bottom;
 DrawText(PaintBox1.Canvas.Handle,PChar(Txt),Length(Txt),TxtRect,DT_LEFT);
End;

procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
 PaintTxt;
end;

end.
Macht genau das, was Du willst.
PaintBox, Edit und Button aufs Form.

Gruß, teebee
  Mit Zitat antworten Zitat