为什么这段代码不能实现位图的从做到右移动!请高手指教
我是想用一个button的onclick控制位图出现并向有移动,可总是不不移动!
现截取代码,请高手帮我分析一下!谢谢
procedure TForm1.Button1Click(Sender: TObject);
const
step=200;
x0=20;
y0=20;
var
bitmap:tbitmap;
midx:integer;
ratiox:real;
i:integer;
rect1,rect2:trect;
begin
bitmap:=tbitmap.create;
bitmap.loadfromfile('a.bmp');//装入本地位图
ratiox:=bitmap.width/step;
for i:=0 to step do
begin
midx:=round(ratiox*i);
with rect1 do
begin
left:=bitmap.width-midx;
top:=0;
right:=bitmap.width;
bottom:=bitmap.height;
end;
with rect2 do
begin
left:=x0;
top:=y0;
right:=x0+midx;
bottom:=y0+bitmap.Height;
end;
canvas.copyrect(rect2,bitmap.Canvas,rect1);//复制位图
end;
bitmap.free;//释放
end;
end.