L
lxddd
Unregistered / Unconfirmed
GUEST, unregistred user!
一个线程画图的程序,如果不运行其它程序始终正常。运行后再执行其它程序,过一
段时间就出问题:PaintBox1的画面不再更新,快则5分钟慢到4小时。画图代码如果用
定时器实现也始终正常。另外98比2000更易出问题。
procedure MyThread.Execute;
var Bmp:TBitmap;
begin
Bmp:=TBitmap.Create;
Bmp.Width:=form1.PaintBox1.Width;
Bmp.Height:=form1.PaintBox1.Height;
Bmp.PixelFormat:=pf16bit;
repeat
Bmp.Canvas.Lock;
form1.PaintBox1.Canvas.Lock;
Bmp.Canvas.FillRect(Rect(0,0,200,200));
Bmp.Canvas.MoveTo(Random(200),Random(200));
Bmp.Canvas.LineTo(Random(200),Random(200));
form1.PaintBox1.Canvas.Draw(0,0,Bmp);
form1.PaintBox1.Canvas.Unlock;
Bmp.Canvas.Unlock;
Sleep(200);
until Terminated;
Bmp.Free;
end;
各位高手,到底哪儿出了问题啊?
段时间就出问题:PaintBox1的画面不再更新,快则5分钟慢到4小时。画图代码如果用
定时器实现也始终正常。另外98比2000更易出问题。
procedure MyThread.Execute;
var Bmp:TBitmap;
begin
Bmp:=TBitmap.Create;
Bmp.Width:=form1.PaintBox1.Width;
Bmp.Height:=form1.PaintBox1.Height;
Bmp.PixelFormat:=pf16bit;
repeat
Bmp.Canvas.Lock;
form1.PaintBox1.Canvas.Lock;
Bmp.Canvas.FillRect(Rect(0,0,200,200));
Bmp.Canvas.MoveTo(Random(200),Random(200));
Bmp.Canvas.LineTo(Random(200),Random(200));
form1.PaintBox1.Canvas.Draw(0,0,Bmp);
form1.PaintBox1.Canvas.Unlock;
Bmp.Canvas.Unlock;
Sleep(200);
until Terminated;
Bmp.Free;
end;
各位高手,到底哪儿出了问题啊?