L
lih544
Unregistered / Unconfirmed
GUEST, unregistred user!
请看:
//定义
TPopupHintFormThread = class;
TPopupHintForm = class(TForm)
private
FTHread: TPopupHintFormThread;
public
proceduredo
Animate;
property THread: TPopupHintFormThread read FTHread write SetTHread;
end;
TPopupHintFormThread = class( TThread )
private
FPopupHintForm: TPopupHintForm;
public
constructor TPopupHintFormThread.Create;
procedure Execute;
override;
end;
//实现
procedure TPopupHintForm.DoAnimate;
begin
Close;
//这里为什么先Close再终结父线程。
//不是close后FTHread所指窗体的内存空间没有了吗?
THread.Terminate;
//这句为什么还可以执行
end;
constructor TPopupHintFormThread.Create;
begin
FPopupHintForm := TPopupHintForm.Create( NIL );
//令这里是否又创建了一个线程
FPopupHintForm.THread := Self;
FPopupHintForm.Show;
Inherited Create( CreateSuspended );
end;
procedure TPopupHintFormThread.Execute;
begin
while not Terminateddo
FPopupHintForm.DoAnimate;
end;
//定义
TPopupHintFormThread = class;
TPopupHintForm = class(TForm)
private
FTHread: TPopupHintFormThread;
public
proceduredo
Animate;
property THread: TPopupHintFormThread read FTHread write SetTHread;
end;
TPopupHintFormThread = class( TThread )
private
FPopupHintForm: TPopupHintForm;
public
constructor TPopupHintFormThread.Create;
procedure Execute;
override;
end;
//实现
procedure TPopupHintForm.DoAnimate;
begin
Close;
//这里为什么先Close再终结父线程。
//不是close后FTHread所指窗体的内存空间没有了吗?
THread.Terminate;
//这句为什么还可以执行
end;
constructor TPopupHintFormThread.Create;
begin
FPopupHintForm := TPopupHintForm.Create( NIL );
//令这里是否又创建了一个线程
FPopupHintForm.THread := Self;
FPopupHintForm.Show;
Inherited Create( CreateSuspended );
end;
procedure TPopupHintFormThread.Execute;
begin
while not Terminateddo
FPopupHintForm.DoAnimate;
end;