In the thread to which the message will be posted, call PeekMessage
(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE) to force the system to
create the message queue.
FOwnerDestroy:TNotifyEvent;
procedure MyDestroy(Sender:TObject);
在构造过程中添加:
FOwnerDestroy:=FOwner.OnDestroy;
FOwner.OnDestroy:=MyDestroy;
在析构过程中:
if Assigned(FOwner) then
FOwner.OnDestroy:=FOwenrDestroy;
procedure MyDestroy;
begin
FillChar(FMessage, Sizeof(FMessage),0);
FEvent.SetEvent;
FThread.Terminate;
if Assigned(FOwner) then
FOwner.OnDestroy:=FOwenrDestroy;