It works fine in our applications.

Primoz

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Arno Garrels
Sent: Saturday, June 02, 2007 8:08 PM
To: ICS support mailing
Subject: Re: [twsocket] ICS v5 compatibility / WndProc handling

Looks usefull, though not tested yet. Francois, what do you think? 

Primož Gabrijelcic wrote:
> Hello everybody (and especially Francois).
> 
> I have this legacy code that was written using ICS v5. Deep inside
> some 
> message processing (specifically RAS handling) is done in overridden
> WndProc 
> methods.
> 
> When I switched to ICS v6, this code broke. This was mainly expected -
> ICS 
> v6 cannot know which socket's WndProc it should call when it receives
> some 
> non-internal (not registered via AllocateMsgHandler) message after
> all. 
> Still, I had to make old code work with the new message dispatch
> system and 
> that's what I did:
> 
> I defined new event handler in the TIcsWndHandler:
> 
>   TIcsOnMessageEvent = procedure(Sender: TObject; var MsgRec:
> TMessage) of 
> object; //Gp
> 
>   TIcsWndHandler = class(TObject)
>     FOnMessage     : TIcsOnMessageEvent;
>   ...
>     property OnMessage: TIcsOnMessageEvent read FOnMessage write
> FOnMessage; 
> //Gp
> 
> In the TIcsWndHandler.WndProc, I call OnMessage if specified:
> 
> procedure TIcsWndHandler.WndProc(var MsgRec: TMessage);
> var
>     Dummy : Boolean;
> begin
>     try
>         with MsgRec do begin
>             if (Msg >= FMsgLow) and
>                (Msg < (FMsgLow + WH_MAX_MSG)) and
>                Assigned(FMsgMap[Msg - FMsgLow]) then
>                 FMsgMap[Msg - FMsgLow].WndProc(MsgRec)
>             else begin
>                 if assigned(OnMessage) then //Gp
>                   OnMessage(Self, MsgRec);  //Gp
>                 if Result = 0 then          //Gp
>                   Result := DefWindowProc(Handle, Msg, wParam,
> lParam); 
>             end;
>         end;
>     except
>         // Les exceptions doivent etre gérées, sinon l'application
> sera 
>         // liquidée dcs qu'une exception se produit !
>         on E:Exception do
>             TriggerBgException(E, Dummy);
>     end;
> end;
> 
> This way, I can catch all messages received by the TIcsWndHandler and
> call 
> appropriate legacy code inside my OnMessage handler.
> 
> I think this is a simple extension that adds much flexibility and
> that I 
> should be included in the base code.
> 
> What do others think?
> 
> Best regards,
> Primoz
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

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

Reply via email to