看看下面的代码对你有没有启发:<br>const UDF_SOCKETEVENT = WM_USER+500;<br>type<br> TComponent1 = class(Tcomponent)<br> private<br> FWindowHandle: HWND;<br> FOnMySocket : TNotifyEvent;<br> procedure WndProc(var Msg: TMessage);<br> protected<br> procedure MySocket; dynamic;<br> public<br> constructor Create(AOwner: TComponent); override;<br> destructor Destroy; override;<br> procedure proc1;<br> Published<br> property OnMySocket: TNotifyEvent read FOnMySocket <br> write FOnMySocket;<br> end;<br><br>...<br><br>constructor TComponent1.Create(AOwner: TComponent);<br>begin<br> inherited Create(AOwner);<br> FWindowHandle := AllocateHWnd(WndProc);<br>end;<br><br>destructor TComponent1.Destroy;<br>begin<br> DeallocateHWnd(FWindowHandle);<br> inherited Destroy;<br>end;<br><br>procedure TComponent1.WndProc(var Msg: TMessage);<br>begin<br> with Msg do<br> if Msg = UDF_SOCKETEVENT then<br> MySocket<br> else<br> Result := DefWindowProc(FWindowHandle, Msg, wParam, lParam);<br>end;<br><br>procedure TComponent1.MySocket;<br>begin<br> if Assigned(FOnMySocket) then FOnMySocket(Self);<br>end;<br><br>procedure TComponent1.proc1 ;<br>var<br> PopSocket : boolean;<br>begin<br> POPSocket:=NetPop.OpenSocketConnection(FWindowHandle,<br> UDF_SOCKETEVENT,110);<br> ...<br><br>end;<br>