Re: IDocHostUIHandler GetExternal question



eselk@xxxxxxxxxxxx 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


.



Relevant Pages

  • Getting braces into pdfobj, for a Document-level JavaScript. HOW?
    ... I am trying to teach myself how to make Document-level JavaScript ... 0 obj ... My LaTeX file, with its false definitions ...
    (comp.text.tex)
  • Re: JavaScriptConverter for Bitmaps
    ... javascript does not have a bitmap datatype so there is nothing to serialize to. ... var obj = Sys.Serialization.JavaScriptSerializer.deserialize; ... public override object Deserialize(IDictionarydictionary, Type type, JavaScriptSerializer serializer) ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: How to pass a byte[] from C# to JavaScript
    ... If I remember, you can't do that with JavaScript, because JavaScript only works with Variant types internally. ... It's been awhile, but I have returned System.Arraylist of objects and was able to walk the ArrayList of objects and access their accessor properties returned to a JavaScript Variant object. ... However, I was doing this using AjaxPro for .Net, which is free to use. ...
    (microsoft.public.dotnet.languages.csharp)
  • Why pass array from CDhtmlDialog to javascript fail
    ... window.external function in javascript. ... VARIANT CMyHtmlDlgDlg::GetSrInfo ... and I have return a uint or BSTR, The javascript will work, only when return ... I wanna know what other should I do for CDHtmlDialog. ...
    (microsoft.public.vc.atl)
  • Why pass array from CDhtmlDialog to javascript fail
    ... window.external function in javascript. ... VARIANT CMyHtmlDlgDlg::GetSrInfo ... and I have return a uint or BSTR, The javascript will work, only when return ... I wanna know what other should I do for CDHtmlDialog. ...
    (microsoft.public.win32.programmer.ole)

Loading