假如下述代码实现label的循环向上移动:
procedure TForm1.upMoveTimerTimer(Sender: TObject);
begin
if label1.top>=label1.height+40 then //若尚未达到最上端
begin
label1.top:=label1.top-1;
label1.caption:=str;
end
else
label1.top:=form1.height-70;//底部位置
end;
那么,再添加一个nextTimer,实现label1.caption字符串内容的不断变换。即:当程序启动,label首先载入字符串并从底部上移,当判断达到顶部,就载入下一个不同的字符串再次从底部上移,如此不断循环。
本人鄙陋,操弄不好两个timer的关系。希望高手指点!
procedure TForm1.upMoveTimerTimer(Sender: TObject);
begin
if label1.top>=label1.height+40 then //若尚未达到最上端
begin
label1.top:=label1.top-1;
label1.caption:=str;
end
else
label1.top:=form1.height-70;//底部位置
end;
那么,再添加一个nextTimer,实现label1.caption字符串内容的不断变换。即:当程序启动,label首先载入字符串并从底部上移,当判断达到顶部,就载入下一个不同的字符串再次从底部上移,如此不断循环。
本人鄙陋,操弄不好两个timer的关系。希望高手指点!
解决方案 »
- ExpressQuantumGrid3.22有没有汉化文件
- 如何用delphi写一个能被PB调用的DLL,谁写过的能给个例子
- 江湖救急:TWebBrower组件调用的网页,在打开新网页的时候,无法向新页面传递session参数值?
- 求救:DLL中的HOOK问题,是关于做游戏外挂的,发放源码
- 精英请赐教:如何把Excel文件转换为word
- 使用ADOquery删除数据,提示数据类型不匹配,望赐教?
- 救急
- 请问,sql2000个人版能否安装在xp下?为什么会有这样的错误信息???
- where have the book <<Delphi高级开发指南>> ,thanks very much
- 一个简单控件的源程序,有谁可以添加点注释!
- 程序已运行,如何打开其所属文件
- 实时新闻系统 系统设置思路 征集中
未到最上端,只要移动就可以了
到了最上端就移动到底部,同时换字符串
StrList: TStringList;
index: integer;
StrList := TStringList.Create;
index := 0;
StrList.Items.Add('Aaaaaaaaaa');
StrList.Items.Add('Bbbbbbbbbb');
StrList.Items.Add('Cccccccccc');
StrList.Items.Add('Dddddddddd');
procedure TForm1.upMoveTimerTimer(Sender: TObject);
begin
if label1.top>=label1.height+40 then //若尚未达到最上端
begin
label1.top:=label1.top-1;
label1.caption:=str;
end
else
begin
label1.top:=form1.height-70;//底部位置
str := StrList.Items.Strings[index];
inc(index);
if index >= StrList.Count then index := 0;
end;
end;
var
idx:shortint;
function TForm1.ShowDifferentText(Num: shortint): widestring;
var//自定义
strlist:Tstringlist;
begin
case Num of
1:begin
strlist:=Tstringlist.Create ;
strlist.LoadFromFile(extractFilepath(application.ExeName)
+'textf\a.txt');
result:=strlist.Text ;
strlist.Free ;
end;
2:begin
strlist:=Tstringlist.Create ;
strlist.LoadFromFile(extractFilepath(application.ExeName)
+'textf\b.txt');
result:=strlist.Text ;
strlist.Free ;
end;
3:begin
strlist:=Tstringlist.Create ;
strlist.LoadFromFile(extractFilepath(application.ExeName)
+'textf\c.txt');
result:=strlist.Text ;
strlist.Free ;
end;
4:begin
strlist:=Tstringlist.Create ;
strlist.LoadFromFile(extractFilepath(application.ExeName)
+'textf\d.txt');
result:=strlist.Text ;
strlist.Free ;
end;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if label1.top>=label1.height+40 then
label1.top:=label1.top-1
else
begin
label1.top:=form1.height-70;
label1.Caption := ShowDifferentText(idx);
inc(idx); edit1.Text :=inttostr(idx) ; //验证一下
if idx>=4 then
idx := 0;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
timer1.Enabled :=true;
label1.top:=self.height;
label1.Font.Color :=clred;
idx:=0;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
timer1.Enabled :=false;
timer1.Interval :=10;
label1.Left :=200;
label1.Width :=360;
label1.Height:=350;
label1.Transparent:=true;
label1.Parent.DoubleBuffered :=true;
end;
可以实现上移再返回底部时加载另外一个文件。但存在问题是:1.当idx为1时,不出现label ,最终只循环显示3个文件 2.上移到顶部(又返回)的位置与文件的行数有关。行数越多,上移位置越低。而我希望每次上移都到窗体顶部才返回底部!
我是菜鸟一个,请高人们完善这个程序!
procedure TForm1.upMoveTimerTimer(Sender: TObject);
begin
if 未到达顶端 then //若尚未达到最上端
begin
...
label1.caption:='未到达顶端';
end
else //到达顶端
begin
label1.caption:='到达顶端';
...
end;
end;