可用RichEdit编辑de下飞字幕程序:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Buttons, ComCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
Image1: TImage;
BitBtn1: TBitBtn;
RichEdit1: TRichEdit;
procedure Timer(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
x,tt,l,h:integer;
pic:Trect;
implementation
{$R *.dfm}
procedure TForm1.Timer(Sender: TObject);
begin
x:=x-1;
tt:=tt-1;
if x<-860 then
x:=image1.Width+20;
tt:=x+80;
//图象离字幕的距离
image1.Canvas.Font.Size:=18;
//字体大小
image1.Canvas.Font.Color:=$1200ffff;
//字体颜色
image1.Canvas.TextOut(x,200,Richedit1.Text);
//要显示的文字。
image1.Canvas.MoveTo(h+x+50-2,0);
image1.Canvas.LineTo(h+x+50-2,l-20);
image1.Canvas.Pen.Color:=clGreen;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
timer1.Enabled:=True;
timer1.Interval:=1;
x:=image1.Height+40;
tt:=x+80;
Form1.Repaint;
image1.Canvas.Brush.Color:=clGreen;
pic:=Rect(0,0,image1.Width,image1.Height);
image1.Canvas.FillRect(pic);
end;
end.