Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Trap messages in IDocHostShowUI::ShowMessage with IE 9 installed

104 views
Skip to first unread message

Jan Ostedt

unread,
Jul 26, 2011, 10:33:23 AM7/26/11
to
Hello,
I have a MFC application that hosts the web browser control. It is a web browser with special features for language
learning. The idea is to give the user the opportunity to work on authentic texts by visiting various web pages. This
means of course that I have no control over which web pages that are accessed. The application has a feature by which
the user can highlight words on the visited web page. If the user has modified a web page by means of this feature and
the web page reloads itself automatically all the modifications will disappear. This is of course a problem. I came up
with a solution to this problem after a discussion in this news group a couple of years ago. See:

http://groups.google.com/group/microsoft.public.inetsdk.programming.webbrowser_ctl/browse_thread/thread/9eb2c2300cb84b92/2c25c3f7094440dd?q=reload+ostedt

At that time I described the solution like this:

In my event sink for window events I added a handler for the OnBeforeUnload event. That event is fired when a javascript
location.reload() is executed. The event handler returns a string that will be added to a message box asking the user if
he or she wants to proceed or not. In my implementation of IDocHostShowUI::ShowMessage I trap that message before it is
displayed using the string to identify it. I supply IDCANCEL via the plResult output parameter to simulate a click on
the cancel button and return S_OK to not show the message box and voila, that's it.

Now, the problem is that this doesn't work if IE 9 is installed. With IE 9 installed it is no longer possible to trap
the message that is related to the OnBeforeUnload event handler in IDocHostShowUI::ShowMessage. It doesn't show up
there. I can trap other messages but not this one. Is this a deliberate change or is this a bug? Any help, comments or
suggestions would be greatly appreciated.

Best Regards
Jan

www.learnware.se

0 new messages