没经过验证的::) var left ,right:boolean;//left:向右移,right:向左移 count :integer; count:=0;//空字符个数 left:=true; right:=false;timer1.timer event: var s,ss:string; begin s:=' ';//含一个空字符 ss:=form1.caption;
if (left) then do begin inc(count); ss:=trim(ss); for i:=0 to count-1 do ss:=s+ss; form1.caption:=ss; if (form1.width==strlen(ss)) then do begin right:=true; left:=false; exit; end; end; if (right) then do begin dec(count); ss:=trim(ss); for i:=0 to count-1 do ss:=s+ss; if (pos(ss,s)<>0) then do begin left=true; right=false; exit; end; end; end;
var left ,right:boolean;//left:向右移,right:向左移
count :integer;
count:=0;//空字符个数
left:=true; right:=false;timer1.timer event:
var
s,ss:string;
begin
s:=' ';//含一个空字符
ss:=form1.caption;
if (left) then do
begin
inc(count);
ss:=trim(ss);
for i:=0 to count-1 do
ss:=s+ss;
form1.caption:=ss;
if (form1.width==strlen(ss)) then do begin right:=true; left:=false; exit; end;
end;
if (right) then do
begin
dec(count);
ss:=trim(ss);
for i:=0 to count-1 do
ss:=s+ss;
if (pos(ss,s)<>0) then do begin left=true; right=false; exit; end;
end;
end;