R
rprince
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TMainForm = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
MainForm: TMainForm;
implementation
{$R *.dfm}
var
GlobalStr:string;
type
TTLSThread=class(TThread)
private
FNewStr:string;
protected
procedure Execute override;
public
constructor Creat(const ANewStr:string);
end;
procedure SetShowStr(const S:String);
begin
if S = '' then
MessageBox(0,PChar(GlobalStr),'The string is',MB_OK)
else
GlobalStr:= S;
end;
constructor TTLSThread.Creat(const ANewStr:String);
begin
FNewStr:=ANewStr;
inherited Creat(False);//have question
end;
procedure TTLSThread.Execute;
begin
FreeOnTerminate:= True;
SetShowStr(FNewStr);
SetShowStr('');
end;
procedure TMainForm.Button1Click(Sender: TObject);
begin
SetshowStr('Hello world');
SetShowStr('');
TTLSThread.Creat('Dilbert');
Sleep(100);
SetShowStr('');
end;
end.
此程序编译出问题
error undelcared identifier"Creat"
error incompatible types : String and Boolean
Fatal error could not compile used unit1 unit1.pas
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TMainForm = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
MainForm: TMainForm;
implementation
{$R *.dfm}
var
GlobalStr:string;
type
TTLSThread=class(TThread)
private
FNewStr:string;
protected
procedure Execute override;
public
constructor Creat(const ANewStr:string);
end;
procedure SetShowStr(const S:String);
begin
if S = '' then
MessageBox(0,PChar(GlobalStr),'The string is',MB_OK)
else
GlobalStr:= S;
end;
constructor TTLSThread.Creat(const ANewStr:String);
begin
FNewStr:=ANewStr;
inherited Creat(False);//have question
end;
procedure TTLSThread.Execute;
begin
FreeOnTerminate:= True;
SetShowStr(FNewStr);
SetShowStr('');
end;
procedure TMainForm.Button1Click(Sender: TObject);
begin
SetshowStr('Hello world');
SetShowStr('');
TTLSThread.Creat('Dilbert');
Sleep(100);
SetShowStr('');
end;
end.
此程序编译出问题
error undelcared identifier"Creat"
error incompatible types : String and Boolean
Fatal error could not compile used unit1 unit1.pas