当前位置:编程学习 > Delphi >>

delphi线程怎么搞

答案:unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;

type
TForm1 = class(TForm)

btn1: TButton;

btn2: TButton;

procedure btn2Click(Sender: TObject);

private

{ Private declarations }
public

{ Public declarations }
end;

{ TThreadClass }

{ TThreadClass }

TThreadClass = class(TThread)
private

protected

public

procedure Execute;override;

procedure NewThread;
published

end;


var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TThreadClass.Execute;
begin
FreeOnTerminate:=True;
//
Synchronize(NewThread);
NewThread;

end;

procedure TThreadClass.NewThread;
var
newbmp: TBitmap;
i,bmpheight,bmpwidth:integer;

begin

newbmp:= TBitmap.Create;
newbmp.Width:=500;
newbmp.Height:=200;
bmpwidth:=500;
bmpheight:=200;
newbmp.LoadFromFile('aa.bmp');
for i:=0 to bmpwidth do
begin
form1.Canvas.CopyRect(Rect(0,0,i,bmpheight),newbmp.Canvas,Rect(0,0,bmpwidth-i,bmpheight));
sleep(10);
end;
newbmp.free;


end;


procedure TForm1.btn2Click(Sender: TObject);
begin
TThreadClass.Create(False);
end;

end.

上一个:delphi 变量的问题
下一个:有关delphi的问题

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,