Re: IHTMLDocument3 getElementById fails but not when I interpose a messagebox
- From: "Igor Tandetnik" <itandetnik@xxxxxxxx>
- Date: Sat, 4 Jun 2005 09:54:27 -0400
"Mark" <mark6139@xxxxxxxxx> wrote in message
news:1117861498.477432.227160@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> I figured it had something to do with the delay but I tried to
> replicate the delay in other ways (i.e. Sleep) and it didn't behave
> the
> same way.
Sleep() does not allow window messages to be processed. WebBrowser is a
single-threaded component - if you suspend the thread it is running on,
it obviously cannot make any progress.
> //view class containing the browser instance
> class CHTMLView : public CWindowImpl<CHTMLView, CAxWindow>,
> public IDispEventImpl<1,
> CHTMLView,
> &DIID_DWebBrowserEvents2,
> &LIBID_SHDocVw,1,1>
>
> BEGIN_SINK_MAP(CHTMLView)
> SINK_ENTRY_INFO(1,DIID_DWebBrowserEvents2,DISPID_DOCUMENTCOMPLETE,
> OnDocumentComplete, &OnDocumentCompleteInfo)
> END_SINK_MAP()
How is OnDocumentCompleteInfo set up?
> };
>
> And to create the view:
>
> myView.Create(m_hWnd, rect, "about:blank", WS_VSCROLL | WS_CHILD |
> WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
>
> m_MyView.SetExternalDispatch(static_cast<IMyControlUI*>(this));
>
> CComPtr<IWebBrowser2> webBrowser;
> m_MyView.QueryControl(&webBrowser);
> if (webBrowser)
> DispEventAdvise(webBrowser,&DIID_DWebBrowserEvents2);
m_MyView is the one that's derived from IDispEventImpl, right? Yet you
call DispEventAdvise on some other class, the one that has m_MyView as a
member. But somehow you still expect CHTMLView::OnDocumentComplete to be
called, even though you never called CHTMLView::DispEventAdvise. I'm
confused.
> Now the event does not seem to be firing.
I wonder why.
> Also, I have another object that fires events (in that case the
> control
> containing the view, rather than the view itself, is derived from
> IDispEventImpl to catch the events). When I call DispEventAdvise on
> that as well as the web browser, the assertion failure occurs (at the
> time the page loads) which mentions m_dwEventCookie.
That's because you are trying to subscribe the same sink twice to two
different objects. IDispEventImpl only knows how to store one advise
cookie, so when you try to advise it a second time, it asserts.
--
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
.
- References:
- Prev by Date: Re: IHTMLDocument3 getElementById fails but not when I interpose a messagebox
- Next by Date: Re: Muliple framed webpage scroll position
- Previous by thread: Re: IHTMLDocument3 getElementById fails but not when I interpose a messagebox
- Next by thread: Re: IHTMLDocument3 getElementById fails but not when I interpose a messagebox
- Index(es):
Relevant Pages
|