Re: Overloading script engine from IHTMLDocument::get_Script
- From: "Igor Tandetnik" <itandetnik@xxxxxxxx>
- Date: Wed, 22 Nov 2006 14:54:38 -0500
Si <blueturtle@xxxxxxxxxxx> wrote:
1) > var old_func1 = window.func1; // read property, store pointer
2) > window.func1 = function(msg) { // put your own implementation
into property
3) > // Do something
4) > old_func1(msg); // call Invoke(DISPID_VALUE) on the stored
pointer
5) > }
That's what I tried, but with no success.
for line 1, the only thing that returned some result was:
//== start code
DISPID putid = dispid; // value from GetDispID
params.rgdispidNamedArgs = &putid;
hr = pDispEx->InvokeEx(DISPID_VALUE,
LOCALE_USER_DEFAULT,
DISPATCH_PROPERTYGET,
¶ms,
&varResult,
&ei,
NULL);
Why are you passing DISPID_VALUE? You want to retrieve a named property,
not a default property - you need to obtain a valid DISPID with
GetIdsOfNames or GetDispId.
Realize that you are dealing with 3 (three) separate objects here. One
is the global script object you obtain with IHTMLDocument::get_Script.
It has lots of different properties and methods - in particular, every
JavaScript global variable or function is acutally a property of global
script object. You can obtain a function by reading an appropriately
named property from this object, and you can override a function by
setting the same.
Now, when you read a property that is in fact a function, what you get
back is an object (separate and distinct from the global script object,
not to be confused with it) that implements a single method with a
dispid of DISPID_VALUE. This method is the actual body of the function.
To override a function, you have to provide your own function object,
which is, again, a COM object implemeting one method with a dispid of
DISPID_VALUE.
--
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
.
- Follow-Ups:
- References:
- Overloading script engine from IHTMLDocument::get_Script
- From: Dave
- Re: Overloading script engine from IHTMLDocument::get_Script
- From: Igor Tandetnik
- Re: Overloading script engine from IHTMLDocument::get_Script
- From: Dave
- Re: Overloading script engine from IHTMLDocument::get_Script
- From: Igor Tandetnik
- Re: Overloading script engine from IHTMLDocument::get_Script
- From: Si
- Re: Overloading script engine from IHTMLDocument::get_Script
- From: Igor Tandetnik
- Re: Overloading script engine from IHTMLDocument::get_Script
- From: Si
- Re: Overloading script engine from IHTMLDocument::get_Script
- From: Igor Tandetnik
- Re: Overloading script engine from IHTMLDocument::get_Script
- From: Si
- Re: Overloading script engine from IHTMLDocument::get_Script
- From: Igor Tandetnik
- Re: Overloading script engine from IHTMLDocument::get_Script
- From: Si
- Overloading script engine from IHTMLDocument::get_Script
- Prev by Date: Re: Overloading script engine from IHTMLDocument::get_Script
- Next by Date: Invoke htmlelement event sometome failed, why?
- Previous by thread: Re: Overloading script engine from IHTMLDocument::get_Script
- Next by thread: Re: Overloading script engine from IHTMLDocument::get_Script
- Index(es):