CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    3

    Dynamic Event Handlers

    Hi all :

    How do you dynamically create an event handler for a COM object ? Specifically, I need to create a vtable dynamically so that it implements dual interface (event) described by the type library of the COM server. This is much like what VB does when it generates a skeleton event handler for any arbitrary COM object.

    Any help is greatly appreciated.

    Regards,
    Amitava
    CA-TCG Software Pvt. Ltd.


  2. #2
    Join Date
    May 1999
    Posts
    48

    Re: Dynamic Event Handlers

    See IConnectionPoint::Advise, Unadvise. Ask target for IConnectionPointContainer, find your event, and then Advise. Don't forget to Undavise.
    Sincerely, Mihai


  3. #3
    Join Date
    Apr 1999
    Posts
    3

    Re: Dynamic Event Handlers

    Hi Mihai :

    I was actually referring to runtime synthesis of a vtable so that I could create a sink implementation on the fly.

    Let's say I discover (at runtime) that CLSID_XX has an event interface IID_ISomething & it is defined as follows :

    interface ISomething : IDispatch
    {
    HRESULT OnSomething();
    }

    However, I've no way of having a pre-defined ISomething implementation. I could ofcourse have a generic IDispatch implementation. However, for the connection point to work, this implementation must succeed when IID_ISomething is queried for .
    IConnectionPoint::Advise() queries for the interface it represents. But then I am breaking the contract that ISomething promised namely that of supporting OnSomething() as a valid vtable entry. Ofcourse, if the server never calls through the vtable and always uses IDispatch::Invoke() instead, everything is kosher.

    I know VB does that. The question is how ?

    Regards,
    Amitava


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured