Answered by:
WebBrowser and CSS3 ?

Question
-
Hello all,
I have inherited of an application using a WebBrowser control (hosted in a form), used to display a webpage.
I wanted to update the webpage style to use some CSS3 feature (like border radius or box shadow for instance).
So if I update the HTML page and open it using IE9, I can see my new layout. However, when I launch my form, all the CSS3 are stripped (I mean if I do right click / view source, they are present, but they are not rendered).
I i ask webBrowser.Version I get correctly 9.0.8080.16413
Is there any way to "force" the WeBrowser to render the CSS3 attributes ?
Note that I have also tried to update my HTML page to use the HTML5 doctype. This doesn't change anything.
Pierre-Emmanuel Dautreppe Co-Founder of DotNetHub http://www.pedautreppe.com http://www.dotnethub.beThursday, May 12, 2011 2:42 PM
Answers
-
Hi Jarodtweiss,
Web browser control by default runs in compatibility mode unless you set the feature browser emulation registry key. The fact that IE9 is able to render CSS3 correctly and browser control is not seems to suggest browser control is not running in IE9 standards mode.
You'll need to set Browser emulation feature key (FEATURE_BROWSER_EMULATION) described at this link http://msdn.microsoft.com/en-us/library/ee330730%28v=vs.85%29.aspx
You can use 9000 value, unless you want to force IE 9 standards mode for all pages. In case of later, you need to use 9999.
hklm
If hklm and 64bit machine used, you need to check is Wow6432Node needs to be changed.
And finally you need to add process name hosting browser control as value name in the registry key.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION]
"prevhost.exe"=dword:00001f40
"sllauncher.exe"=dword:00001f40
"WindowsFormsApplication1.exe"=dword:0000270f
Best wishes,
Mike [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Marked as answer by Jarodtweiss Tuesday, May 24, 2011 8:46 AM
Thursday, May 19, 2011 2:45 PM
All replies
-
The webbrowser is a resuse of the inbuild IE you are using, the name is shdocvw.dll
Success
CorFriday, May 13, 2011 6:42 AM -
Hi Jarodtweiss,
It seems that the IE9 web browser only support parts of the css3 and html5 futures.
And the WebBrowser windows form control is used the web browser core system is using.
What do you mean about your description?
Do you mean some future is supported by your IE9 but not supported in your WebBrowser in your environment?
And Please provide the files.
You can upload them to the "sky driver", and then share the download link to us in your post.
If there's any concern, please feel free to let us know.
Best wishes,
Mike [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Friday, May 13, 2011 7:17 AM -
Yes exactly ! Some features are displayed in IE9 but not in the WebBrowser. Here is a basic example :
Chek the example here : http://cid-1f1bef1607ef881d.office.live.com/self.aspx/MSDN%20-%20WebBrowser%20-%20CSS3
I have
- Page.html : the page I want to render
- Page.jpg : the rendering I have from this page in IE9
- WindowsFormsApplication1.exe : a form, hosting a WebBrowser, that displays the Page.html (must be in the same folder as the exe)
- Form.jpg : the rendering I have within the form
As you can see, everything is correct in IE9, but in the form all the CSS3 attributes are not displayed.
Pierre-Emmanuel Dautreppe Co-Founder of DotNetHub http://www.pedautreppe.com http://www.dotnethub.beFriday, May 13, 2011 8:04 AM -
Hey,
We got it.
And we need more time to research this question.
Maybe cannot show you a quick response while we are researching it.
If there's any concern, please feel free to let us know.
Have a nice weekend!
Mike [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Saturday, May 14, 2011 3:56 AM -
Hi Jarodtweiss,
Web browser control by default runs in compatibility mode unless you set the feature browser emulation registry key. The fact that IE9 is able to render CSS3 correctly and browser control is not seems to suggest browser control is not running in IE9 standards mode.
You'll need to set Browser emulation feature key (FEATURE_BROWSER_EMULATION) described at this link http://msdn.microsoft.com/en-us/library/ee330730%28v=vs.85%29.aspx
You can use 9000 value, unless you want to force IE 9 standards mode for all pages. In case of later, you need to use 9999.
hklm
If hklm and 64bit machine used, you need to check is Wow6432Node needs to be changed.
And finally you need to add process name hosting browser control as value name in the registry key.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION]
"prevhost.exe"=dword:00001f40
"sllauncher.exe"=dword:00001f40
"WindowsFormsApplication1.exe"=dword:0000270f
Best wishes,
Mike [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Marked as answer by Jarodtweiss Tuesday, May 24, 2011 8:46 AM
Thursday, May 19, 2011 2:45 PM -
Thanks ! great info, it works like a charm after having updated the registry.
For extra information, if you want this to work also when debugging in VS, add "WindowsFormApplication1.vshost.exe"
Pierre-Emmanuel Dautreppe Co-Founder of DotNetHub http://www.pedautreppe.com http://www.dotnethub.beTuesday, May 24, 2011 8:48 AM