|
|
|
date: Wed, 17 Oct 2007 15:35:28 -0700,
group: microsoft.public.inetsdk.programming.webbrowser_ctl
back
IDocHostUIHandler GetExternal question
If I implement IDocHostUIHandler::GetExternal, can the IDispatch
object I return, have methods that return other IDispatch objects, and
can objects from JavaScript be passed as parameters as well?
So in JavaScript I would do something like this:
obj = window.external.createMyObject();
obj.DoSomething();
Does JavaScript just treat all objects as IDispatch, if not, how does
it know what type of object/variable the "createMyObject" function
returned? Well, I guess I might know the answer to that, since COM
uses variant params, and my Invoke function sets the variant type that
it returns... I guess that is how JavaScript knows the variable type,
right?
Maybe this is a JavaScript question, so if I don't get an answer here,
I'll try one of those groups.
By the way, I'm using C++ to implement IDocHostUIHandler (which is why
I know how the variant type gets set by the Invoke function, not set
by the run-time engine for you).
date: Wed, 17 Oct 2007 15:35:28 -0700
author: unknown
Re: IDocHostUIHandler GetExternal question
eselk@surfbest.net wrote:
> If I implement IDocHostUIHandler::GetExternal, can the IDispatch
> object I return, have methods that return other IDispatch objects, and
> can objects from JavaScript be passed as parameters as well?
Yes and yes.
> So in JavaScript I would do something like this:
>
> obj = window.external.createMyObject();
> obj.DoSomething();
Quite possible.
> Does JavaScript just treat all objects as IDispatch
Yes.
> how does
> it know what type of object/variable the "createMyObject" function
> returned?
It doesn't know nor care.
> Well, I guess I might know the answer to that, since COM
> uses variant params, and my Invoke function sets the variant type that
> it returns... I guess that is how JavaScript knows the variable type,
> right?
Well, that's how it distinguishes an object from a primitive value like
an integer or a string. But all objects look the same to it (stored in
VARIANT of type VT_DISPATCH).
--
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
date: Wed, 17 Oct 2007 18:45:57 -0400
author: Igor Tandetnik
|
|