Re: IHTMLDocument3 getElementById fails but not when I interpose a messagebox



"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


.



Relevant Pages

  • Re: newbie questions
    ... There is also a fundamental difference between delay and sleep: ... latter two refer to user-land operations (which will be implemented using kernel facilities). ... Mostly you delay execution in user space for a lengthy period of time, so implementing this as a busy-wait "delay" would be a waste of processor power and also of electric power as busy-waiting will keep the processor executing instructions while putting a process/thread into some queue might permit you to actually halt the processor because no other process/thread is ready for execution. ...
    (comp.os.linux.development.system)
  • Re: I NEED HELP
    ... order the delay, and if Julie hardly tops it too, the pool will ... sleep unlike the competent rock. ...
    (sci.crypt)
  • Basic thread questions
    ... several software-hardware interfaces. ... loop with a sleep of equal duration (on the theory that sleep both ... When I adjust the test app's sleep to a 500ms delay, ...
    (comp.programming.threads)
  • Re: Making a program pause
    ... run a for loop that waits until 5 minutes has passed to continue down ... How can I implement a delay, or time a user's response, ... setitimer, sleep(), Sleep, times, and usleep. ... only clock() is part of the ANSI Standard. ...
    (comp.lang.c)