Re: Events from the WebBrowser control



"Norman Bullen" <norm@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:r3PAh.2273$tD2.699@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
The MSDN documentation for DWebBrowserEvents2 says that it derives
indirectly from IDispatch and shows members such as BeforeNavigate2
and NavigateComplete2.

It doesn't derive from IDispatch - it _is_ IDispatch. It's a so called
dispinterface. A dispinterface is IDispatch plus the description of
which DISPIDs are valid, what they mean and which parameters should
accompany each.

Thus, BeforeNavigate2 is not a method in COM interface sense - it
doesn't correspond to a vtable entry. Calling this "method" means
calling IDispatch::Invoke with a dispid of DISPID_BEFORENAVIGATE2 and a
particular set of parameters in DISPPARAMS structure.

I have some sample code that compares at the DISPID_xxx names
associated with the dispinterface functions with the dispIdMember
argument that is passed to DWebBrowserEvents2::Invoke().

Is this the best/only way to handle these events in C++?

Not if you are willing to use libraries designed to help one write COM
code. E.g. ATL provides IDispEventImpl class specifically to implement
event sinks that are dispinterfaces (the most common kind). See
ATLBrowser sample.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.



Relevant Pages

  • Re: Events from the WebBrowser control
    ... It doesn't derive from IDispatch - it _is_ IDispatch. ... A dispinterface is IDispatch plus the description of which DISPIDs are valid, what they mean and which parameters should accompany each. ... BeforeNavigate2 is not a method in COM interface sense - it doesn't correspond to a vtable entry. ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)
  • Re: Pure dispinterface registration ?
    ... So dispinterface keyword is nothing - it's useful only for type information. ... which points to ISum ... (I checked - I can define IDispatch variables without errors.) ... IDispatch" do you have difficulty understanding? ...
    (microsoft.public.win32.programmer.ole)
  • Re: IDispatch and dispinterface
    ... dispinterface and dual interface is exclusive ... coclass YourComponent3 ... interface and only expose IDispatch? ...
    (microsoft.public.vc.language)
  • Re: Whats dispinterface and whats the difference between
    ... A dispinterface is IDispatch plus a specification of which DISPIDs are valid, what they mean and what parameters should accompany them in an Invoke call. ... This arrangement is typically used for dual interfaces. ...
    (microsoft.public.vc.atl)
  • Re: Pure dispinterface registration ?
    ... Or I must derive directly from IDispatch? ... class serv: ISum ... How about dispinterface? ...
    (microsoft.public.win32.programmer.ole)