回 帖 发 新 帖 刷新版面

主题:[讨论]怎么样在时钟控件里让图像一张一张的换来显示?

在窗体下有timer1,lmage1二个控件.效果是让图片一张张显示.
时钟属性为 真和1000毫秒.可是用下面代码怎么也运行不了.用了随机函数才能显示出来,可是显示却是随机的图片,不是按顺序来的.
各位大虾有什么好的思路不防教教我.还有怎么写才能像我说的效果显示出来.end;[em18].
procedure TForm8.Timer1Timer(Sender: TObject);
var
  chajutu:integer;
begin
  //randomize;
  //chajutu:=random(4);
  case chajutu of
  1:image1.Picture.LoadFromFile('茶具\自动流水雕龙骨瓷茶具.jpg');
  2:image1.Picture.LoadFromFile('茶具\龙头老大 紫砂茶具.jpg');
  3:image1.Picture.LoadFromFile('茶具\茶叶加茶具.jpg');
  4:image1.Picture.LoadFromFile('茶具\茶叶和茶具.jpg');
  //5:image1.Picture.LoadFromFile('茶具\自动流水雕龙骨瓷茶具.jpg');
  end;

回复列表 (共3个回复)

沙发

var
  chajutu:integer;
chajutu := 1; //初始化变量
procedure TForm8.Timer1Timer(Sender: TObject);
begin
  if chajutu > 4 then
     chajutu := 1;
  case chajutu of
  1:image1.Picture.LoadFromFile('茶具\自动流水雕龙骨瓷茶具.jpg');
  2:image1.Picture.LoadFromFile('茶具\龙头老大 紫砂茶具.jpg');
  3:image1.Picture.LoadFromFile('茶具\茶叶加茶具.jpg');
  4:image1.Picture.LoadFromFile('茶具\茶叶和茶具.jpg');
  //5:image1.Picture.LoadFromFile('茶具\自动流水雕龙骨瓷茶具.jpg');
  end;
  inc(chajutu);
end;

板凳

[quote]var
  chajutu:integer;
chajutu := 1; //初始化变量
在这里直接报错啦"ldentifier redeclared:'chajutu'"

3 楼

这一句var
  chajutu:integer;你定义成单元变量啊,我这里回复只是一种表示方式

我来回复

您尚未登录,请登录后再回复。点此登录或注册