数据类型不兼容 (50分)

  • 主题发起人 主题发起人 sharknt
  • 开始时间 开始时间
S

sharknt

Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure ThreadsDone(Sender:TObject);
public
{ Public declarations }
end;

TFooThread=class(TThread)
protected
procedure Execute;override;
end;

var
Form1: TForm1;
implementation
{$R *.DFM}
const
MaxSize=128;
var
NextNumber:integer=0;
do
neFlags:integer=0;
GlobalArray:array[1..MaxSize]of integer;
function GetNextNumber:integer;
begin
Result:=NextNumber;
Inc(NextNumber);
end;

procedure TFooThread.execute;
var
I:integer;
begin
OnTerminate:=TForm1.ThreadsDone;
//问题就出在这,谁能帮助我
for I:=1 to MaxSizedo
begin
GlobalArray:=GetNextNumber;
Sleep(5);
end;
end;

procedure TForm1.ThreadsDone(Sender:Tobject);
var
I:integer;
begin
Inc(DoneFlags);
ifdo
neFlags=2 then
for i:=1 to MaxSizedo

Listbox1.items.add(IntToStr(GlobalArray));
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
TFooThread.Create(False);
TFooThread.Create(False);
end;

end.
 
它们的声明应当是下面这样:
property OnTerminate: TNotifyEvent;
type TNotifyEvent = procedure (Sender: TObject) of object;
你检查你的声明是不是?
 
将 ThreadsDone 声明为 TFooThread 的成员:
OnTerminate:=ThreadsDone;
 
不能用TForm1.ThreadsDone ,用Form1.ThreadsDone
 
后退
顶部