Z
zhengli
Unregistered / Unconfirmed
GUEST, unregistred user!
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
TMyThread = class(TThread)
private
Number1Edit, Number2Edit: TEdit;
Number1, Number2: Integer;
Procedure ShowNumber;
protected
procedure Execute;
override;
public
Constructor Create(Edit1, Edit2: TEdit);
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
{ TThread }
constructor TMyThread.Create(Edit1, Edit2: TEdit);
begin
Number1Edit := Edit1;
Number2Edit := Edit2;
Number1 := 0;
Number2 := 0;
// inherited Create(False);
Resume;
end;
procedure TMyThread.Execute;
begin
inherited;
Form1.Canvas.TextOut(100, 100, 'Why');
ShowNumber;
end;
procedure TMyThread.ShowNumber;
var
i: Integer;
begin
For i := 1 to 100000do
begin
Number1Edit.Text := IntToStr(Number1);
Number2Edit.Text := IntToStr(Number2);
Form1.Edit1.Text := IntToStr(Number1);
Form1.Edit2.Text := IntToStr(Number2);
Inc(Number1);
Inc(Number2);
Form1.Canvas.TextOut(10, 10, IntToStr(Number1 + Number2));
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
TMyThread.Create(Edit1, Edit2);
end;
end.
这个程序不能正常运行,总是执行不到
Execute,不知为什么,请各位帮忙查查错。
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
TMyThread = class(TThread)
private
Number1Edit, Number2Edit: TEdit;
Number1, Number2: Integer;
Procedure ShowNumber;
protected
procedure Execute;
override;
public
Constructor Create(Edit1, Edit2: TEdit);
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
{ TThread }
constructor TMyThread.Create(Edit1, Edit2: TEdit);
begin
Number1Edit := Edit1;
Number2Edit := Edit2;
Number1 := 0;
Number2 := 0;
// inherited Create(False);
Resume;
end;
procedure TMyThread.Execute;
begin
inherited;
Form1.Canvas.TextOut(100, 100, 'Why');
ShowNumber;
end;
procedure TMyThread.ShowNumber;
var
i: Integer;
begin
For i := 1 to 100000do
begin
Number1Edit.Text := IntToStr(Number1);
Number2Edit.Text := IntToStr(Number2);
Form1.Edit1.Text := IntToStr(Number1);
Form1.Edit2.Text := IntToStr(Number2);
Inc(Number1);
Inc(Number2);
Form1.Canvas.TextOut(10, 10, IntToStr(Number1 + Number2));
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
TMyThread.Create(Edit1, Edit2);
end;
end.
这个程序不能正常运行,总是执行不到
Execute,不知为什么,请各位帮忙查查错。