How to Implement Invoke for IDispatch

C

Charles Law

Hi guys

There's nothing much going on in Interop at the moment, so I'll post this
here as well in case someone can give me a quick answer.

The following is an extract from MSDN:

<extract>
*** Setting the Ambient User Mode on the WebBrowser Object ***

To set the ambient user mode on the WebBrowser object, first QI the
IWebBrowser2 interface for the IOleControl interface and then call
IOleControl::OnAmbientPropertyChange, passing DISPID_AMBIENT_USERMODE as the
argument.
m_pIWebBrowser2->QueryInterface( IID_IOleControl, (void**)&pIOleCtrl );
pIOleCtrl->OnAmbientPropertyChange( DISPID_AMBIENT_USERMODE );

This causes MSHTML to call IDispatch::Invoke on the host application,
passing along the same DISPID. Of course, for this to work, the host
application has to handle the DISPID_AMBIENT_USERMODE case in its
IDispatch::Invoke implementation, returning VARIANT_TRUE in the pvarResult
parameter to activate the editor or VARIANT_FALSE to deactivate it.
</extract>

My question is, how can my (VB.NET) application implement IDispatch::Invoke
in order to test for the DISPID and return the correct value?

TIA

Charles
 
F

Fergus Cooney

Hi Everybody,

Now hold on, don't all crowd round to answer this one - form an orderly
queue - you'll all get your turn.

Sorry Charles, couldn't resist. ;-D

Regards,
Fergus
 
C

Charles Law

Now look what you've done. They all think that an answer was posted, so no
one is answering.

;-)

Charles
MVP [All things, bright and beautiful]
 
F

Fergus Cooney

Hi Charles,

Take a wander through the System.Runtime.InteropServices Namespace.
There's mention there of IDispatch, DispIds, IDispatchImpls and all sorts of
stuff which is meaningless to your non-C++ programmer. It sounds like you know
what you're talking about - and therefore what you're looking for.

Good luck. :)

Regards,
Fergus
 
F

Fergus Cooney

Hi Charles,

|| They all think that an answer was posted ...

Oops, sorry - that is a possibility. :-(

But I think that extract is more frightening than the Google Man!! 8-O

Actually, C# suffers the same constraints as VB.NET as regards Interop
because it's the Framework more than the language. But the C# crowd will have
a lot of C++/COM people. It might be useful to post to languages.csharp as
well (oh, and leave out the VB word from your query, wink, wink - they're a
delicate lot)

;-)

Regards,
Fergus
 
C

Cor

Hi Charles,
You know that I had to a lot of problems with axWebbrowser.
What I do than is delete it totaly and just start again.
And then I was never able to recreate the errors I had.
(Until I start moving with it inside my code and get other strange errors)
I was always thinking that it has to do with the registration of the
webbrowser in the registry,
(That is somewhere written), but never took some time to look what that
means.
Did you?
Cor
 
C

Charles Law

Hi Cor

I haven't looked, but you may have something there because Fergus says his
did not give the same problem on the EndInit() call, I think. I have tried
it on one other machine where it did do the same, but I will look to see if
I can find any info. on the registration.

Cheers

Charles
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top