Re: Pls Help with empty Print Preview

From: Igor Tandetnik (itandetnik_at_mvps.org)
Date: 02/25/05


Date: Fri, 25 Feb 2005 18:37:30 -0500


"Peter Carlson" <peter@__N.O.S.P.A.M__howudodat.com> wrote in message
news:%23HTZ8p2GFHA.2804@TK2MSFTNGP10.phx.gbl
> After the document is loaded we execute some JS to finish any last
> minute changes in the html (ie set the default date). If I use
> document->write then I can InvokeScript, if I use the Stream I can't
> - it cant find the script...GetIDOfName cant find the javascript
> function, however, view source shows it's there. I have checked
> both calling Invoke...from OnNavComplete and from a handler for
> window.external.onLoad (which is called in ondocumentready).

Did you try handling DocumentComplete event?

> Below
> is the InvokeScript Call:
>
> HRESULT InvokeScript(LPCOLESTR lpszName, VARIANT* pvarParam1 = NULL,
> VARIANT* pvarRet = NULL) {
> CComPtr<IHTMLDocument2> pDocument; m_pBrowser->get_Document(
> (LPDISPATCH *) &pDocument );

You can't do this. get_Document returns IDispatch pointer. You store it
in an IHTMLDocument2 pointer. This amounts to downcasting from base to
derived interface, which is illegal in COM. You have to use
QueryInterface to navigate between interfaces. The only exception is
going from derived to base interface, but not the other way round.

-- 
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: Pls Help with empty Print Preview
    ... get_Document returns IDispatch pointer. ... This amounts to downcasting from base to ... > derived interface, ... > going from derived to base interface, but not the other way round. ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)
  • Re: Good COM Interface Design
    ... of a base interface when implementing a derived interface then ... of the method of the original base interface. ... You may have to maintain different interface pointers in different ...
    (microsoft.public.vc.atl)
  • Re: TlbExp and inherited interfaces lost
    ... To get around this problem, you must duplicate the methods from the base interface into the derived interface, with each method preceeded by the new keyword. ... new void Init(); ...
    (microsoft.public.dotnet.framework.interop)
  • Re: IContextMenu and IContextMenu question
    ... Interface inheritance doesn't work the way you expect with COM ... You have to include all methods of the base interface ... (IContextMenu here) ... in the derived interface. ...
    (microsoft.public.dotnet.framework.interop)
  • Re: What can I query from pointer to event handler?
    ... > Given an IDispatch pointer to an event handler function obtained from ... What interface do you expect it to implement, beyond IUnknown and ... What on earth else might one want to do with an event handler? ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)