首页  编辑  

多行文本输出到画布

Tags: /超级猛料/Friends.网友专栏/zswang/函数大全/   Date Created:
(*//
标题:多行文本输出到画布
说明:示例滚屏效果
设计:Zswang
日期:2002-01-25
支持:wjhu111@21cn.com
//*)
/// ////Begin Source
procedure TextToCanvas(mStrings: TStrings; mCanvas: TCanvas; mOffset: TPoint);
{ 将多行文本输出到画布上 }
var
    I: Integer;
    vTextHeight: Integer;
begin
    with mStrings, mCanvas do
    begin
        vTextHeight := TextHeight('|');
        for I := 0 to Pred(Count) do
            TextOut(mOffset.X, mOffset.Y + vTextHeight * I, Strings[I]);
    end;
end; { TextToCanvas }

/// ////End Source
/// ////Begin Demo
procedure TForm1.Timer1Timer(Sender: TObject);
const
{$J+}
    vTop: Integer = -MaxInt; // for Delphi6.0
{$J-}
begin
    if vTop <= -Memo1.Lines.Count * Image1.Canvas.TextHeight('|') then
        vTop := Image1.ClientHeight
    else
        Dec(vTop);
    Image1.Canvas.FillRect(Image1.ClientRect);
    TextToCanvas(Memo1.Lines, Image1.Canvas, Point(0, vTop));
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
    DoubleBuffered := True; // for Delphi6.0
    { Image1.Transparent := True; //背景 }
    Timer1.Interval := 50;
    Timer1.Enabled := True;
end;
/// ////End Demo