5,386
社区成员
发帖
与我相关
我的任务
分享
procedure TIOCPSEVER1.callback(S:tsocket;Even:integer);stdcall;
begin
PostMessage(FwindowHandle,wm_user+Even,s,0);
end;
在控件初始化时:
procedure TIOCPSEVER1.SetActive(const Value: boolean);
begin
if value then
begin
if not FActive then
begin
if init(@TIOCPSEVER1.callback,Fport) then FActive := Value;
end;
end
else
begin
if FActive then
begin
shutdown;
FActive := value;
end;
end;
end;
VC++底层初始化时将m_pNotifyProc=TIOCPSEVER1.callbac。
消息处理函数:
procedure TIOCPSEVER1.WndProc(var Msg: TMessage);
begin
with msg do
case Msg of
(WM_USER+0):
begin
end;
(WM_USER+1):
begin
if Assigned(OnConnect) then
OnConnect(WParam);
end;
(WM_USER+2):
begin
if Assigned(OnDisConnect) then
OnDisConnect(WParam);
end;
(WM_USER+3):
begin
if Assigned(OnTransmit) then
OnTransmit(WParam);
end;
(WM_USER+4):
begin
DoExecute(WParam);
end;
(WM_USER+5):
begin
if Assigned(ONTRANSMITSucess) then
ONTRANSMITSucess(WParam);
end;
else
Result := DefWindowProc(FWindowHandle, Msg, wParam, lParam);
end;
end;
我想要是能改下TIOCPSEVER1.callback(S:tsocket;Even:integer);这个改成向线程中发送消息,在线程完成事件处理应该可以改善下。