0

I'm working with an MFC application (C++). We use embedded browsers in some dialogs - IWebBrowser2 ActiveX objects. By default, they emulate IE version 7 (for compatibility reasons). We need a newer version to be able to display modern webpages, so we change IE version by setting the registry key FEATURE_BROWSER_EMULATION. (See this blogpost or other SO questions on the subject.)

But when we change to a newer IE for embedded browsers, a third party module we use crash. It turns out that it too uses a (hidden) IWebBrowser2 object, and it can't handle a modern IE. (Updating the third party module is not an option right now.)

The third party module isn't used often, so we tried solving it by changing the FEATURE_BROWSER_EMULATION temporary. But that doesn't work! It seems like FEATURE_BROWSER_EMULATION is only read the first time an IWebBrowser2 object is created. If you do like this:

 (1)  Set FEATURE_BROWSER_EMULATION to 7000 (=IE7)
 (2)  Create a dialog box with an IWebBrowser2 control (and navigate to "thismachine.info")
 (3)  Close the dialog box
 (4)  Set FEATURE_BROWSER_EMULATION to 11001 (=IE11)
 (5)  Create a dialog box with an IWebBrowser2 control (and navigate to "thismachine.info")

both IWebBrowser2 controls will be IE7! (If you swap 7000/11001 both will be IE11.) Despite that the whole dialog, the browser control and the first IWebBrowser2 object get deallocated in step (3).

Is there any way to get two IWebBrowser2 objects to use different IE versions in the same process? What's causing this - is there some "registry cache" in the COM handling, causing the new registry value to be ignored? (If so, is there a way to clear that cache?) Or is there some part of the first IWebBrowser2 object that isn't deallocated? (If so, is there a way to do that?) Or do anyone have a different approach/suggestion?

UglySwede
  • 429
  • 1
  • 7
  • 16
  • You never note, whether you control the pages, that should be displayed using IE11. If you do, you can control the instance the `IWebBrowser2` control uses by setting an appropriate `X-UA-Compatible` HTML meta tag. This, too, is explained in the blog entry you linked to. – IInspectable Jan 06 '17 at 19:13
  • Hi, at most, given a legacy dependency for IE7 and lower, an emulation mode of IE10 should be used.... IE11's Edge mode does not support VBScript, JScript, attachEvent and other proprietary events and methods. https://msdn.microsoft.com/en-us/library/bg182625(v=vs.85).aspx .... use the client web browser to load your markup (copy from your dll resources to a html file (must have mark of the web) and open them in IE.... Use the IE11 emulation tab to experiment with different Emulation modes. – Rob Parsons Jan 07 '17 at 06:20
  • Thanks for your input! To clarify: Our main problem with the third-party-module, is that we get a "The webpage you are viewing is trying to close the window. Do you want to close this window?" message from the (hidden) IWebBrowser2 object when emulating IE11. If you answer Yes, the module stops working. The hidden IWebBrowser2 object navigates to JavaScript code, that loads a lot of other code. We cannot change the webpages. Is there a way to stop this message? (We could live with other peculiarities for now.) I've tried put_Silent, but it didn't help, and I can't find any other way. – UglySwede Jan 07 '17 at 09:44

0 Answers0