在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
引用 http://www.cnblogs.com/del/archive/2011/05/18/2049913.html
{自定义方法: 在窗体上绘制...} procedure MyMethod; var i: Integer; begin for i := 0 to 500000 do begin Form1.Canvas.Lock; Form1.Canvas.TextOut(10, 10, IntToStr(i)); Form1.Canvas.Unlock; end; end; {调用上面的自定义方法} procedure TForm1.Button1Click(Sender: TObject); begin MyMethod; end;
procedure MyMethod; var i: Integer; begin for i := 0 to 500000 do begin Form1.Canvas.Lock; Form1.Canvas.TextOut(10, 10, IntToStr(i)); Form1.Canvas.Unlock; end; end; procedure TForm1.Button1Click(Sender: TObject); begin TThread.CreateAnonymousThread(MyMethod).Start; //!!! end;
procedure TForm1.Button1Click(Sender: TObject); begin TThread.CreateAnonymousThread( //直接写入方法体 procedure var i: Integer; begin for i := 0 to 500000 do begin Canvas.Lock; Canvas.TextOut(10, 10, IntToStr(i)); Canvas.Unlock; end; end //此处无分号 ).Start; end;
var myThread: TThread; procedure TForm1.FormCreate(Sender: TObject); begin myThread := TThread.CreateAnonymousThread( procedure var i: Integer; begin for i := 0 to 500000 do begin Canvas.Lock; Canvas.TextOut(10, 10, IntToStr(i)); Canvas.Unlock; end; end ); end; procedure TForm1.Button1Click(Sender: TObject); begin myThread.Start; end;
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论