注:wordVorg、wordHorg、wordmemoVorg、wordmemoHorg分别表示移动方向
procedure TForm1.Timer1Timer(Sender: TObject);
begin
//单词开始移动
if wordVorg then
begin
if word.top>=1 then word.top:=word.top-1 else wordVorg:=False;
end
else
begin
if word.top<=form1.ClientHeight-word.Height then word.top:=word.top+1 else wordVorg:=True;
end;
if wordHorg then
begin
if word.left>=1 then word.left:=word.left-1 else wordHorg:=False;
end
else
begin
if word.left<=form1.ClientWidth-word.Width then word.left:=word.left+1 else wordHorg:=True;
end;
//释义开始移动
if wordmemoVorg then
begin
if wordmemo.top>=1 then wordmemo.top:=wordmemo.top-1 else wordmemoVorg:=False;
end
else
begin
if wordmemo.top<=form1.ClientHeight-wordmemo.Height then wordmemo.top:=wordmemo.top+1 else wordmemoVorg:=True;
end;
if wordmemoHorg then
begin
if wordmemo.left>=1 then wordmemo.left:=wordmemo.left-1 else wordmemoHorg:=False;
end
else
begin
if wordmemo.left<=form1.ClientWidth-wordmemo.Width then wordmemo.left:=wordmemo.left+1 else wordmemoHorg:=True;
end;
end;