Discussion:
Refresh and attaching IHTMLEditDesigner
(too old to reply)
jwallison
2004-10-29 18:22:19 UTC
Permalink
In a .Net BHO, I need to be able to attach an IHTMLEditDesigner to a web
document
in IE whenever a top-level document completes loading.

I have a solution that traps document_complete and works fine, but refresh
does not fire this event, does not fire beforeNavigate2 etc.

What can I do to detect completion of loading of the top-level document and
attach my IHTMLEditDesigner to the document(s) (including top-level doc in a
frameset) after it has finished loading?.

I need to be able to

a) detect when the topmost doc is loaded after a refresh or
document_complete
b) attach my IHTMLEditDesigner at that point

I see one other "idea" on the subject in the
inetexplorer.ie5.programming.components.webbrowser_ctl NG as follows:

"I've seen claims that one can implement IOleCommandTarget on the client
site object, and WebBrowser will call Exec(OLECMDID_REFRESH) upon
refresh. I haven't tried it myself.".

Could someone weigh-in with an idea that they KNOW is "workable"?

Thanks -
--
Regards,

Jim Allison
***@bellsouth.net
(de-mung by removing '.1')
John
2004-11-01 22:51:20 UTC
Permalink
Hi, Jim

I spoke to the escalation (cpr) lead for this technology and he provided
the following:

Q180366 answers the question of determining DocumentComplete correctly for
the most part. Some cases like Refresh, script urls, page aborts etc have
to be dealt with specially.


CAUSES:

- Refresh does not fire navigate and document complete events.

- Script URLs like javascript: and vbscript: only fire BeforeNavigate event.

- There was no way to detect an aborted download unless we set a timer in
BeforeNavigate2 and check the readyState.


The following KB article explains how to detect that a page is done loading
completely but there are a few cases that need special handling.


http://support.microsoft.com/support/kb/articles/Q180/3/66.ASP



- Refresh does not fire navigate and document complete events, use
DownloadBegin and DownloadEnd events instead (start checking this if there
was
no prior BeforeNavigate event fired that was not already matched up with a
corresponding DocumentComplete). A feature request has been logged that all
events be fired even for Refresh.



- For script urls(eg: javascript: or vbscript: ), ignore the BeforeNavigate
events since they don't fire any other events.



- There is no way currently to detect page aborts since all events may not
fire
(NavigateComplete, DocumentComplete etc) The only solution is to set a
timer
to some appropriate value (2-3mins) in BeforeNavigate and if DocComplete
hasn't fired by then check the readyState of the document and if complete
assume page abort.



- Another specific scenario was when a frame reloads itself (with a diff
url)
before the final DocumentComplete fires for the frameset page. You can get
a
BeforeNavigate for the frame a second time but the DocumentComplete for
this
sometimes fires after the final DocumentComplete. It can be reasoned that
since the frame had reached readyState complete state once we can assume
that
the final DocumentComplete can fire. This may be by design currently, but I
went ahead and logged an additional bug report for this since it doesn't
seem
reasonable for final DocumentComplete to fire though one of the frames is
not
in readyState complete state.



A workaround for this problem was to match up the number of BeforeNavigate2
to
DocumentComplete calls to figure out if all documents were completely
loaded
including the frame reloads that start before final DocumentComplete fires.
Increment an int value for every BeforeNavigate2 and decrement it for
every
DocumentComplete call. If this value is zero when you see a DownloadBegin,
then it's a refresh operation.


You can use the DownloadEnd event to try to get the document object. I
assume you have an interface to the web browser control, so you can call
IWebBrowser2::get_Document to obtain the IHTMLDocument object. Since you
won't know if the document is ready, you can watch the ReadyState event.

Once you get the document object, you can QI for IServiceProvide and then
call QueryService for IHTMLEditServices. Once you get that interface, you
can call AddDesigner to pass your own IHTMLEditDesigner.

I realize that this is not taylor made for your needs. I hope that it is
sufficient to get you going.

Thank you for choosing the MSDN Managed Newsgroups,

John Eikanger
Microsoft Developer Support

This posting is provided “AS IS” with no warranties, and confers no rights.

--------------------
| From: "jwallison" <***@nospam.net>
| Subject: Refresh and attaching IHTMLEditDesigner
| Date: Fri, 29 Oct 2004 14:22:19 -0400
| X-Tomcat-NG: microsoft.public.windows.inetexplorer.ie5.programming.misc
|
| In a .Net BHO, I need to be able to attach an IHTMLEditDesigner to a web
| document
| in IE whenever a top-level document completes loading.
|
| I have a solution that traps document_complete and works fine, but refresh
| does not fire this event, does not fire beforeNavigate2 etc.
|
| What can I do to detect completion of loading of the top-level document
and
| attach my IHTMLEditDesigner to the document(s) (including top-level doc
in a
| frameset) after it has finished loading?.
|
| I need to be able to
|
| a) detect when the topmost doc is loaded after a refresh or
| document_complete
| b) attach my IHTMLEditDesigner at that point
|
| I see one other "idea" on the subject in the
| inetexplorer.ie5.programming.components.webbrowser_ctl NG as follows:
|
| "I've seen claims that one can implement IOleCommandTarget on the client
| site object, and WebBrowser will call Exec(OLECMDID_REFRESH) upon
| refresh. I haven't tried it myself.".
|
| Could someone weigh-in with an idea that they KNOW is "workable"?
|
| Thanks -
|
|
| --
| Regards,
|
| Jim Allison
| ***@bellsouth.net
| (de-mung by removing '.1')
|
|
|
|

Loading...