Robert,

You have to check for Msg.hwnd = 0 otherwise your custom message 
IDs will probably conflict which TWSocket's own messages like:

while GetMessage(MsgRec, 0, 0, 0) do
begin
  if MsgRec.hwnd = 0 then {<== ** VERY IMPORTANT ** }
  begin
    Handle messages posted to this thread through PostThreadMessage()    
  end
  else begin  
    // Other messages posted to some window handle in this thread // 
    TranslateMessage(MsgRec);
    DispatchMessage(MsgRec);   
  end;

Also if you overrode TWSocket's WndProc method to handle own, custom
messages posted to TWSocket's window handle those custom messages 
MUST be allocated by overriding three more methods in ICSv6+, 
here's an example:

{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
function TCustomFtpCli.MsgHandlersCount : Integer;
begin
    Result := 3 + inherited MsgHandlersCount;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TCustomFtpCli.AllocateMsgHandlers;
begin
    inherited AllocateMsgHandlers;
    FMsg_WM_FTP_REQUEST_DONE := FWndHandler.AllocateMsgHandler(Self);
    FMsg_WM_FTP_SENDDATA     := FWndHandler.AllocateMsgHandler(Self);
    FMsg_WM_FTP_CLOSEDOWN    := FWndHandler.AllocateMsgHandler(Self);
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TCustomFtpCli.FreeMsgHandlers;
begin
    if Assigned(FWndHandler) then begin
        FWndHandler.UnregisterMessage(FMsg_WM_FTP_REQUEST_DONE);
        FWndHandler.UnregisterMessage(FMsg_WM_FTP_SENDDATA);
        FWndHandler.UnregisterMessage(FMsg_WM_FTP_CLOSEDOWN);
    end;
    inherited FreeMsgHandlers;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}

BTW: Method PutDataInSendBuffer() actually _is thread-safe, so there is
no need to copy data a second time to a custom buffer.

-- 
Arno Garrels

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to