title: WebBrowser control set Document Mode
body: <p>So I know about <a href="http://msdn.microsoft.com/en-us/library/ie/ee330730%28v=vs.85%29.aspx#browser_emulation" rel="nofollow noreferrer">FEATURE_BROWSER_EMULATION</a>, but either it isn't working for me, or it only controls the Browser Mode and not the Document Mode.</p>
  
  <p>I have a lot of info specific to my case below, but the general question that I think/hope should have an easy answer that applies to lots of people is: <strong>How do I get the WebBrowser control to render exactly like whatever version of IE the user has installed?</strong>  I think this comes down to control over the "Document Mode"</p>
  
  <hr>
  
  <p>I'm trying to get the WebBrowser control to render HTML the same way IE10 does, without modifying the HTML (because that isn't robust).  My app is an email client that displays HTML email, and here is what a typical email from GMail might look like:</p>
  
  <pre><code>&lt;div dir="ltr"&gt;&lt;div id="" team-id="21062" dir="ltr"&gt;&lt;div id="email-body-container" style="width:96%; padding:0; margin:2%; border:solid 1px #E7E7E7;"&gt;
    &lt;div id="email-body-header" style="width:94%; padding:3% 3% 2% 3%; background-color:#f5f5f5; border-bottom:solid 1px #eaeaea;"&gt;
      &lt;img src="http://www.google.com/adwords/htp/static/legacy/adwords_logo_grey_166x28.png" alt="Google AdWords" width="166" height="28" style="outline:none; text-decoration:none; -ms-interpolation-mode: bicubic; display:block;"&gt;
    &lt;/div&gt;
  &lt;/div&gt;&lt;/div&gt;
  </code></pre>
  
  <p>I have that exact HTML in a file named c:\test.htm, and I load it in IE by entering that in the address bar, and then I load it in the webbrowser control using <code>Navigate("c:\\test.htm")</code>, and they don't render the same.</p>
  
  <p>I know it isn't valid HTML because it doesn't even include an html tag, body tag, etc, but this is how GMail does things and I have no control over that (or other weird stuff email clients do).  The only thing I do know is that Internet Explorer always seems to display them nicely (probably most people test with IE, that's why).  However, they don't display nicely in the WebBrowser control.  Here is the above HTML in IE10 (Win8) and in a simple WinForms app using the WbeBrowser control:</p>
  
  <p><img src="https://i.stack.imgur.com/Lofhi.png" alt="enter image description here"></p>
  
  <p>The WinForms app has a scrollbar when one isn't needed, and also the border doesn't match the background color size.  Using IE developer tools I can try every combination of Browser Mode (IE7 through IE10) and every combo of Document Mode (standards, quirks, IE7 - IE9 standards) and the only way I can get IE to render like the WebBrowser control is to set the Document Mode to "IE5 quirks".  In which case it renders the same as the WebBrowser control even if Browser Mode is set to IE10.</p>
  
  <p>I've set this registry value:
  HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\WindowsFormsApplication2.exe</p>
  
  <p>I've tried setting it to 10000, 10001, 9999, 8888, 9000, and a few other values (decimal, not hex) and they have no effect on this issue.  My EXE name is WindowsFormsApplication2.exe, and I've set my build to x64 and confirmed it is running as a 64-bit process, so that I don't have to worry about setting Wow6432Node instead (but I even tried setting that also).</p>
  
  <p>So I'm thinking that only controls the Browser Mode, but not the Document Mode?  I tried the obsolete FEATURE_NATIVE_DOCUMENT_MODE setting also, no change.</p>
  
  <p>Note, I tagged this as TWebBrowser also because I originally found this issue using that, but since hardly anyone uses that I made sure I could recreate in a real simple .NET C# WinForms app.</p>
  
  <hr>
  
  <p><strong>Added May 17th:</strong></p>
  
  <p>Here is a reg export (I deleted everything under HKCU just to make sure it wasn't overriding anything in HKLM):</p>
  
  <p>Windows Registry Editor Version 5.00</p>
  
  <pre><code>[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION]
  "prevhost.exe"=dword:00001f40
  "HelpPane.exe"=dword:00002710
  "sllauncher.exe"=dword:00001f40
  "test.exe"=dword:00002710
  "iexplore.exe"=dword:00002711
  "windowsformsapplication2"=dword:00002710
  "windowsformsapplication2.exe"=dword:00002710
  "test"=dword:00002710
  </code></pre>
  
  <p>Here is what my "test.exe" looks like in Task Manager:</p>
  
  <p><img src="https://i.stack.imgur.com/6qZSC.png" alt="enter image description here"></p>