C
crasyProg
Unregistered / Unconfirmed
GUEST, unregistred user!
我使用线程向导创建了一个线程类,在线程Destroy时我向主窗体postmessage,可是主窗体捕捉有时能捕捉到消息,有时就莫名其妙的捕捉不到!这是怎么回事呢?DFW帮帮小弟我吧,谢谢了
代码如下:
线程类:
private
myControl:Tcontrol;//控件名称假设的
MyThread.Execute;
begin
try
myControl:=Tcontrol.create(nil);
... //myControl一些属性付值
myControl.timeout=1000;
myControl.do();
myControl.OnSucess=myThreadSucess;
while not terminateddo
application.processmessage;
finally
myControl.free;
end;
end;
destruct Mythread.destroy;
begin
postmessage(fom1.handle,wm_threadMsg,0,0);
inherit;
end;
主窗体代码
主线程Unit1
const
wm_threadMsg=wm_message+100;
procedure wmthreadmsg(msg:Tmsg):messages;wm_threadMsg;
begin
myThread.create()..//再创建一个线程
application.p..
end;
代码如下:
线程类:
private
myControl:Tcontrol;//控件名称假设的
MyThread.Execute;
begin
try
myControl:=Tcontrol.create(nil);
... //myControl一些属性付值
myControl.timeout=1000;
myControl.do();
myControl.OnSucess=myThreadSucess;
while not terminateddo
application.processmessage;
finally
myControl.free;
end;
end;
destruct Mythread.destroy;
begin
postmessage(fom1.handle,wm_threadMsg,0,0);
inherit;
end;
主窗体代码
主线程Unit1
const
wm_threadMsg=wm_message+100;
procedure wmthreadmsg(msg:Tmsg):messages;wm_threadMsg;
begin
myThread.create()..//再创建一个线程
application.p..
end;