在窗体中怎样实现字体滚动? 在窗体中怎样实现字体滚动? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 有很多方法,简单的是用一个Timer控制Label,定时让其Left := Left + 1,若超过再设其初值,这种方法不太好,有明显的抖动现象。一个好的方法是,用Image来显示,再Image上用Canvas画字,下面贴一些代码:var Form1: TForm1; x, tt, l, h: integer; pic: Trect; map: Tbitmap;implementation{$R *.dfm}procedure TForm1.Timer1Timer(Sender: TObject);begin x := x - 1; tt := tt - 1; if x < -160 then x := image1.height + 20; tt := x + 80; image1.Canvas.font.size := 18; image1.Canvas.font.color := clLime; image1.Canvas.TextOut(10,x,'OK 字 幕 移 动 演 示'); image1.Canvas.font.size:=12; image1.Canvas.font.color:= clLime; image1.Canvas.TextOut(20,x+50,' 字 体 变 色 效 果 演 示'); l:=image1.Canvas.textwidth(' 字 体 变 色 效 果 演 示'); h:=image1.Canvas.textheight(' 字 体 变 色 效 果 演 示'); image1.Canvas.pen.color:=clGreen; image1.Canvas.moveto(20,h+x+50-2); image1.Canvas.lineto(20+l,h+x+50-2); pic.topleft.x:=30; pic.topleft.y:=tt; pic.bottomright.x:=pic.topleft.x+100; pic.bottomright.y:=pic.topleft.y+80; image1.canvas.stretchdraw(pic,map); image1.Canvas.pen.color:=clBlack; image1.Canvas.moveto(0,pic.topleft.y+80); image1.Canvas.lineto(pic.topleft.x+100,pic.topleft.y+80);end;{ 以下设置动画初值}procedure TForm1.FormCreate(Sender: TObject);begin timer1.enabled:=true; timer1.Interval:=25; x:=image1.height+20; tt:=x+80; form1.repaint; image1.Canvas.brush.color:=clBlack; pic:=Rect(0,0,image1.width,image1.height); image1.Canvas.FillRect(pic); pic:=Rect(-1,-1,1,1); map:=Tbitmap.create; map.loadfromfile('d:\\t.bmp'); image1.canvas.stretchdraw(pic,map);end; 大把方法.timer+label字符串控制. 数据库读数据 delphi内存占用 急!!!请大家帮忙关于modem来电显示的问题 哪里有多线程编程资料下载啊?比较详细的~~谢谢 delphi 7 数据库链接问题 难死我了!太难了!谁能帮我解决阿?分不够可以再加!先谢谢了!! dll中的窗口如何以子窗口显示在调用的窗口里 看看这个过程哪里不对,为什么总是提示窗体上的某个组件有错误?! 如何取得和传递用户名?应该在那里申明username? 各位大侠在代码如何改变显示器的分辨率 在远程调用的函数中传递Bitmap图片变量行不行呢?该用什么变量类型啊? 这个功能如何实现?脑子混乱啊!
一个好的方法是,用Image来显示,再Image上用Canvas画字,下面贴一些代码:
var
Form1: TForm1;
x, tt, l, h: integer;
pic: Trect;
map: Tbitmap;implementation{$R *.dfm}procedure TForm1.Timer1Timer(Sender: TObject);
begin
x := x - 1;
tt := tt - 1;
if x < -160 then
x := image1.height + 20;
tt := x + 80;
image1.Canvas.font.size := 18;
image1.Canvas.font.color := clLime;
image1.Canvas.TextOut(10,x,'OK 字 幕 移 动 演 示');
image1.Canvas.font.size:=12;
image1.Canvas.font.color:= clLime;
image1.Canvas.TextOut(20,x+50,' 字 体 变 色 效 果 演 示');
l:=image1.Canvas.textwidth(' 字 体 变 色 效 果 演 示');
h:=image1.Canvas.textheight(' 字 体 变 色 效 果 演 示');
image1.Canvas.pen.color:=clGreen;
image1.Canvas.moveto(20,h+x+50-2);
image1.Canvas.lineto(20+l,h+x+50-2);
pic.topleft.x:=30;
pic.topleft.y:=tt;
pic.bottomright.x:=pic.topleft.x+100;
pic.bottomright.y:=pic.topleft.y+80;
image1.canvas.stretchdraw(pic,map);
image1.Canvas.pen.color:=clBlack;
image1.Canvas.moveto(0,pic.topleft.y+80);
image1.Canvas.lineto(pic.topleft.x+100,pic.topleft.y+80);
end;
{ 以下设置动画初值}
procedure TForm1.FormCreate(Sender: TObject);
begin
timer1.enabled:=true;
timer1.Interval:=25;
x:=image1.height+20;
tt:=x+80;
form1.repaint;
image1.Canvas.brush.color:=clBlack;
pic:=Rect(0,0,image1.width,image1.height);
image1.Canvas.FillRect(pic);
pic:=Rect(-1,-1,1,1);
map:=Tbitmap.create;
map.loadfromfile('d:\\t.bmp');
image1.canvas.stretchdraw(pic,map);
end;
timer+label
字符串控制.