The source code for my WPF Chromium WebBrowser control is now available on CodePlex.
The source includes:
Cjc.ThreeDeemium – The sample application, currently without any 3D features. Go figure.
Cjc.ChromiumBrowser – The WPF Chromium WebBrowser control. Depends on Cjc.AwesomiumWrapper and the two Awesomium / Chromium C++ DLLs (Awesomium.dll and icudt38.dll).
Cjc.AwesomiumWrapper – A Managed C++ / CLI wrapper around Awesomium. This is much easier to maintain than the old P/Invoke stuff, and is almost nice to look at
Awesomium – C++ headers and libraries for Awesomium / Chromium.
There’s also a bonus project
:
Cjc.WebSnapshot – A small command-line utility using Cjc.AwesomiumWrapper to snapshot a URL (you need to specify a full URL including the scheme – http://chriscavanagh.wordpress.com etc).
94 responses so far ↓
A Real WPF WebBrowser « Chris Cavanagh’s Blog // August 25, 2009 at 2:42 pm |
[...] ← WPF Cursor from HCURSOR WPF Chromium WebBrowser source code! [...]
Will // August 25, 2009 at 3:10 pm |
Wow… it worked! Cash! Into my back account! Immediately!
Michael Brown // August 25, 2009 at 9:06 pm |
@will LMAO!
Michael Brown // August 25, 2009 at 9:10 pm |
You know I had a funny incident. I was driving to Madison from Chicago and there was a nasty traffic snarl that turned the highway into a parking lot. My comment to my wife “It’s probably just people staring at an accident. I swear there better be a car just engulfed in flames up ahead.”
Sure enough we get a few miles down and there it was. Not just smoke coming out…this thing was litterally engulfed in flames. That was the first time I felt that traffic congestion was justified.
Dew Drop – August 26, 2009 | Alvin Ashcraft's Morning Dew // August 26, 2009 at 6:59 am |
[...] Cursor from HCURSOR and A Real WPF WebBrowser and WPF Chromium WebBrowser source code! (Chris [...]
WPF, Silverlight et autres… » Archive du blog » WebBrowser WPF // August 26, 2009 at 1:09 pm |
[...] Plus d’info sur le site de Chris Cavanagh ou sur le codeplex de WPF Chromium [...]
FremyCompany // August 26, 2009 at 1:59 pm |
Great ! I we could have the same for the native one…
I noticed some bugs because they are frequently crash when navigating. Can’t remember when, but it’s problematic if you want to use it in a production environement…
Chris Cavanagh // August 26, 2009 at 2:05 pm |
FremyCompany – Any crashes are more likely caused by my demo app than the wrappers or Awesomium/Chromium. If you could send me examples of what causes it to crash I’ll take a closer look.
Keep checking back though; I’ve been publishing a few fixes that might help.
FremyCompany // August 27, 2009 at 6:50 am |
OK, If I have time to re-test it, I’ll send you the debug informations when I encounter an error.
Thanks for your support,
Fremy
Chris Cavanagh // August 27, 2009 at 9:00 am |
FremyCompany – I’ve published a number of bugfixes that might help. Note it won’t work well with Java applets or XBAPs (yet… although I’ve not looked closely at it so far)
Jose Fajardo // August 28, 2009 at 1:31 am |
I was looking for a layout friendly WPF webbrowser. Yo the man !
squid // August 29, 2009 at 8:58 am |
Hi!, I have implement your library in XNA!!!!
http://img19.imageshack.us/img19/6316/screenshot0000q.jpg
bye squid!
Chris Cavanagh // August 29, 2009 at 7:50 pm |
squid – Cool! Do you have a binary I can try? (or a sweet ClickOnce deployment?
)
Chris Cavanagh // August 29, 2009 at 7:55 pm |
squid – It might be my eyes, but the webpage looks a little blurry in the screenshot (compared to the rest). Make sure your backbuffer pixelformat is bgr32 or equivalent (think that’s what Awesomium defaults to). Hope this helps!
Ashkan // August 29, 2009 at 10:20 pm |
hi
i want to know how can we use C++ class libraries with P/invoke?
and i have a problem with the wrapper
i added a reference to the wrapper and put those 2 C++ DLLs in my project folder (i don’t know how can i reference them) and when i try to use the library it says filenotfound exception???
what was wrong in what i did?
Chris Cavanagh // August 30, 2009 at 12:02 am |
Ashkan – There are two native C++ DLLs (Awesomium.dll and icudt38.dll). It seems you can actually omit the icudt38.dll if you don’t need keyboard input or Javascript support (don’t know if that’s deliberate though).
The Cjc.AwesomiumWrapper.dll assembly is a Managed C++ wrapper around Awesomium.dll. You can use it directly in a .NET project with no need for P/Invoke (FYI internally it uses C++/CLI which is more intuitive and easier to work with than P/Invoke).
If you include the two native DLLs, make sure you set them as “Content” (so they’ll get published etc with your project) and set “Copy to output directory (always / if newer; either is fine). I’m guessing the problem is they’re not present in your Debug / Release folder (when running through Visual Studio). There’s no reference as such to the native DLLs; they’re just expected to be in the same folder.
Hope this helps!
squid // August 30, 2009 at 11:22 am |
Hi!, Yes you see blurry because I left the bloom effect in the game. I’m making a custom component with your wrapper library. When I’ve tested I’ll send you the source code. The screenshot is only a test!
bye squid
kal // September 1, 2009 at 11:31 am |
Hi Chris
Is there a way to get the source code? is Awesomium commericalized?
Chris Cavanagh // September 1, 2009 at 12:03 pm |
kal – Right now you need to hunt around for the source code (try here: http://forum.quest3d.com/index.php?topic=67161.45). All existing Awesomium code is open source, but it looks likely later versions won’t be. There’s a v1.5 “coming soon”, but I’m not sure what the licensing terms will be.
In any case, it’ll probably be worth creating a new project on CodePlex (or wherever) with the most recent LGPL source. Most of the hard work has aready been done by Adam (http://princeofcode.com/blog/) so aside from a few tweaks along the way, just periodically rebuild the native DLLs with the latest Chromium source…
If the latest binaries were always readily available for download, it could make a lot of developers very happy (including me; I’ve served my time with C++ already
).
Rune Solberg // September 1, 2009 at 1:01 pm |
Hi Chis!
This is stunning. How did you come up with an idea like this?
The binary run fine, but the window1.xaml in the CJC.ThreeDeemium project reports “The spesified module could not be found. Exception from HRESULT 0×8007007E” and the Address property in the control of that template is marked with an error
So it won’t compile. Strange..
Chris Cavanagh // September 1, 2009 at 1:09 pm |
Rune – If you’re running a debug build, it’s probably looking for Awesomium_d.dll. That’s about 50MB so I didn’t upload it to CodePlex
You could either run in Release, or try these steps to get the debug DLL:
1) Download 3rd.zip.001 – 003 here: http://forum.quest3d.com/index.php?topic=67161.45
2) Merge them into one zip:
copy /b 3rd.zip.001 + 3rd.zip.002 + 3rd.zip.003 3rd.zip
Another option is to get all the Awesomium and Chromium source and build from that… See my earlier comment for some details on it.
Rune Solberg // September 1, 2009 at 1:53 pm |
You were right
The debug dll is the solution.
The xaml viewer inside Visual Studio still goes crazy about this error so the view can’t be redrawn, but it compiles, runs and lookes pretty cool generally.
Could live with that..
Chris Cavanagh // September 1, 2009 at 2:00 pm |
There might be somewhere you can drop the DLL where VS will see (and use) it, although ideally my ChromiumBrowser control should probably be smarter about how it renders at design time… I’ll update here when it’s fixed
Rune Solberg // September 1, 2009 at 2:30 pm |
Thanks for the quick reply Chris! I was just dumping the debug dll into my system folder which VS holds a path reference to and the xaml viewer redraw perfectly!
Even the Address shows up inside the viewer. Cooler than ever.
Chuck Martan // September 3, 2009 at 1:05 pm |
Great post!
One thing I’m attempting to do is use your control to capture a complete image of a webpage. Would you have any ideas on how I would go about that?
Chris Cavanagh // September 3, 2009 at 1:39 pm |
Chuck – This is pretty much what you’d need:
using CAW = CjcAwesomiumWrapper;
…
public static Rect? RenderSnapshot( string url, byte[] buffer, int width, int height )
{
using ( var webCore = new CAW.WebCore() )
{
using ( var webView = webCore.CreateWebView( width, height ) )
{
webView.SetTransparent( true );
var finished = new ManualResetEvent( false );
var listener = new CAW.WebViewListener();
listener.FinishLoading += delegate { finished.Set(); };
webView.SetListener( listener );
if ( url.StartsWith( “file:” ) ) webView.LoadFile( url );
else webView.LoadURL( url );
var timeout = DateTime.Now.AddSeconds( 30 );
while ( !finished.WaitOne( 100 ) )
{
webCore.Update();
if ( DateTime.Now > timeout ) return null;
}
var r = webView.Render( buffer, width * 4, 4 );
return new Rect( r.X, r.Y, r.Width, r.Height );
}
}
}
Chris Cavanagh // September 3, 2009 at 2:14 pm |
Chuck – The CodePlex/SVN source now includes a “WebSnapshot” sample project. It’s a simple command-line utility to save a page snapshot to a file (currently always saves in .PNG format, with transparency… could probably used a few more options to be useful).
Charck Martan // September 4, 2009 at 6:23 am |
THANKS CHRIS!
I appreciate the super fast response and the sample project!
=)
steve // September 4, 2009 at 7:01 am |
Hi Chris,
I try to add some javascript to my web page, but it seems that javascript doesn’t work with your webbrowser
steve // September 4, 2009 at 7:02 am |
oops, my javascript miss
onload=”alert(toto)”
Chuck Martan // September 4, 2009 at 7:30 am |
Hmm 1 Minor problem Chris if you don’t mind taking a quick look at it. I ran the program and it gives me blank png’s of the websites I plug in. I took a look at the code and can’t really find where or what the problem may be. If you get a chance could you give it a look please?
Thanks!
Chuck
Chris Cavanagh // September 4, 2009 at 8:55 am |
steve – Glad it’s working
There’s also the ability to call js methods from outside the control; it’s limited but might be useful.
Chris Cavanagh // September 4, 2009 at 8:59 am |
Chuck – Are you able to step through with the debugger? Make sure the URL you’re using includes the full scheme etc (http://www.google.com); it won’t automatically add those. Also, you might want to change the project to use a BGR32 image and remove the webView.SetTransparent( true ); (I’ll probably remove those anyway; I doubt many users would want transparent backgrounds)
Wayne // September 10, 2009 at 3:35 am |
Hi Chris,
This is great – I’ve extended the control now so you can pass a html string to it instead of a url.
The only thing is I need to be able to get the full size of the html page – any chance you could help me? I’m trying to execute some javascript to return the size using webView.ExecuteJavacriptWith Result but I’m not having much luck!
Thanks,
Wayne
Chris Cavanagh // September 10, 2009 at 7:05 am |
Wayne – Could you send me a test project showing what you’re wanting to achieve? (wayne @ chriscavanagh.com)
John Taylor // September 11, 2009 at 4:11 am |
Can’t get anything to work…looks as though any reference to the Awesomium dlls have been “changed” in codeplex so you can’t use them?…or am I doing something stupid?
John Taylor // September 11, 2009 at 5:09 am |
looks like it’s me being stoopid…(now there’s a suprise
Still getting blank browsers in Threemium and youCube3 projects…but they build, and I can step through the code.
Might be my firewall…
p.s. ignore my last post… I was having a “blonde” moment.
Chris Cavanagh // September 11, 2009 at 6:42 am |
John – Is the browser window all white, or black? If black, it suggests a problem calling the Awesomium methods. It’ll only be white if Awesomium successfully rendered something.
Do the ClickOnce demos work for you, or same problem? Also, are you on an x86 or x64 OS?
John Taylor // September 11, 2009 at 11:15 am |
Hi Chris…it was authentication issues (white pges, not black). When I changed the url to a page on the company intranet I got a page rendered. I’ve searched on it and it looks as though it’s Chromes inability to authenticate based on your windows login info.
Thanks for getting back to me so quickly
Pieter Van Compernolle // November 24, 2009 at 4:09 am |
Chris, John,
I have the same issue (white pages), probably also because of the authentication.
Is there any way to submit user credentials in this control? (Google chrome asks for user credentials via a popup window, but WPF Chromium Browser does not).
Chris Cavanagh // November 25, 2009 at 11:33 am
Pieter – Currently there isn’t a way to submit credentials. I’m kicking around the idea of a managed port of Awesomium (Chromium itself would need to remain native C++ obviously) which could allow us to control pretty much everything… The case for it is certainly building
Wrapper Issue // September 11, 2009 at 5:09 pm |
I’m trying to use the ExecuteJavascriptWithResult function which returns a FutureJSValue but I dont know how to use that with the wrapper. Is that implemented or do i need to tweak it?
Chris Cavanagh // September 12, 2009 at 6:56 am |
Wrapper Issue – It might need some tweaking. I exposed the methods but haven’t tested them yet. If you let me know what you change I’ll update the source (or could add you as a contributor on CodePlex if you prefer).
Lehel // September 12, 2009 at 10:54 am |
I have been playing with it, but getting an exception from my code. Here is the definition:
JSValue^ Get() {
Awesomium::JSValue val = this->value->get();
return %CjcAwesomiumWrapper::JSValue(val);
}
(I wrote it this way because I was trying to overcome an exception being thrown)
When this-value->get() is called and assigned to a new object, an exception is thrown:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt
I was reading up on this exception, and some say it has something to do with the build configuration (i.e., all the files need to be built for x86 for instance). I’ve been experimenting to get past this exception but no dice thus far. I’m wondering if Awesomium_d.dll needs to be built correctly as well or if I just have to worry about the wrapper and whatever the wrapper is using.
Your input would be much appreciated.
Matthew // September 15, 2009 at 11:20 am |
I’m wondering if it’s possible to listen for a javascript callback with your chromium browser. If so, how? -Thanks!
Chris Cavanagh // September 15, 2009 at 11:23 am |
Matthew – It should be, but I’ve not tested it
Fyi there are a bunch of updates to JS interoperability coming in Awesomium v1.5…
Chris Cavanagh // September 15, 2009 at 11:28 am |
Matthew – Take a look at Cjc.AwesomiumWrapper; the JS/callback methods are implemented there but I’ve not exposed them on the WebBrowser control yet. It looks like you call SetCallback and give it the name of a method to “register”, then attach to the Callback event of the WebViewListener (where I’ve mistakenly called the first param ‘url’ instead of name). I can kick this round a bit and post an update if it helps…
Fredrik Løkke // September 16, 2009 at 5:57 am |
Hi
Very nice work!
But.. I’m getting a “Could not create an instance of type ‘WebBrowser’” in the designer.. It compiles and runs fine though.. Any suggestions?
Chris Cavanagh // September 16, 2009 at 7:43 am |
Fredrik – It’s probably because VS can’t see the native DLLs. Also, it might be trying to use the debug version of Awesomium (Awesomium_d.dll); I excluded that from the source as it’s about 50mb (vs 8mb for the release). If you drop the DLLs somewhere VS will look, it should work ok in the designer. Ideally the WebBrowser control should handle design mode better, but would probably need a tweak to load the Awesomium dll dynamically… Hope this helps!
Jesper // September 29, 2009 at 7:47 am |
I have successfully integrated the browser control in my application, and in general it works without flaws and obeys my WPF transforms etc. – great
BUT I do have a huge problem, though – trying to instantiate the Cjc.ChromiumBrowser object on an x64 OS makes the application crash (tried both XP x64 and Vista x64). The hosting application is not x64 itself, but it has always run nicely on x64, as any windows application should be able to do. Now it starts up fine and work ok, until you bring up the window containing the Cjc.ChromiumBrowser component. Then it crashes immediately:
Cannot create instance of ‘WebBrowser’ defined in assembly ‘Cjc.ChromiumBrowser, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’. Exception has been thrown by the target of an invocation.
The inner exception is that the module or one of it dependencies cannot be found. Everything is fine when OS is not x64.
Have someone experienced (or even solved) this?
Thanks,
Jesper.
Jesper // September 30, 2009 at 3:12 am |
Just for the record – the problem turned out to be related to the hosting application being built for “Any CPU” (VS project settings) and the browser components and wrapper being built for x86. This difference caused a runtime crash on x64 OS. Changing the hosting application build settings to x86 fixed the problem.
Best regards,
Jesper.
Chris Cavanagh // September 30, 2009 at 9:04 am |
Jesper – Thanks! I’d hoped it was something like that
The joys of native code…
ralph marczynski // October 1, 2009 at 12:32 pm |
Chris – Great Stuff! Thanks for enabling all of us to get even more creative with WPF!
Any idea as to why PDF documents won’t open. For example, the following address does not work:
http://www.irs.gov/pub/irs-pdf/fw4.pdf
Chris Cavanagh // October 1, 2009 at 12:53 pm |
ralph – It looks like it “tries” to open; it shows Adobe Reader’s dark gray background. It might be the same problem that affects some Silverlight apps which need to use the browser’s HTTP stack (Silverlight 3 has its own networking stack, but you have to “opt in” afaik).
This might be something that’s resolved with the next version of Awesomium; unfortunately the latest available Awesomium source doesn’t play nicely with the latest Chromium source
(so can’t just go and rebuild it). We’ll need to see if/how there remains an open-source version of Awesomium beyond v1.5…
Brett Burkhart // October 5, 2009 at 2:26 pm |
I grabbed the latest from CodePlex, Set #29203, and even after removing the missing files from the projects, and making sure the Awesomium DLL’s are in the Cjc.ThreeDeemium bin, I get an error trying to run the demo project. Am I missing something simple here? Is there not a SLN that works out of the box?
“Cannot create instance of ‘WebBrowser’ defined in assembly ‘Cjc.ChromiumBrowser, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’. Exception has been thrown by the target of an invocation. Error at object ‘grid’ in markup file ‘Cjc.ThreeDeemium;component/window1.xaml’ Line 22 Position 4.”
Chris Cavanagh // October 5, 2009 at 2:47 pm |
Brett – Is this a runtime error, or is it thrown by VS’s designer? If VS, you’ll need to make sure you have Awesomium_d.dll somewhere VS can find it (it’s a native DLL). The solution should build fine otherwise, but let me know if that’s not the case
Brett Burkhart // October 5, 2009 at 3:00 pm |
The error is a runtime error. I don’t have the Awesomium_d.dll as it was one of the missing file in the project, which I removed. I don’t seem to see the Awesomium_d.dll anywhere else in the ZIP, except in the Awesomium/lib, but it’s just a lib, not dll. Where do I get the Awesomium_d.dll?
Brett Burkhart // October 5, 2009 at 3:04 pm |
wpfchromium-29203.zip
Out of the box, the projects are missing files. FYI.
– Cjc.WebSnapshot –> missing
Awesomium.dll
Awesomium_d.dll
icudt38.dll.
– Cjc.ThreeDeemium –> missing
Awesomium_d.dll
Chris Cavanagh // October 5, 2009 at 3:34 pm |
Brett – Do a quick search through the comments above for Awesomium_d.dll. Basically it’s a huge file so it wasn’t practical for me to put on CodePlex, but currently you’ll need it if you’re running a debug build. There’s a forum link posted in the earlier comments which should help.
Note the Awesomium DLLs (Awesomium, Awesomium_d and icudt38) aren’t built by me. The latest Awesomium source I’ve got doesn’t build against the latest Chromium source, so unless someone’s able to throw some time at this (either fix Awesomium, or get the relevant older Chromium version to build against), we’re stuck with these binaries until Adam (http://princeofcode.com/about.php) clarifies which direction he’s going with licensing future versions.
For Cjc.WebSnapshot, just copy Awesomium.dll/icudt38.dll into its folder.
Hope this helps!
Chris Cavanagh // October 5, 2009 at 3:40 pm |
Brett – Also note you don’t need to build WebSnapshot; it’s just an example of using Awesomium from the command line
Brett Burkhart // October 6, 2009 at 7:46 am |
Got it, I’ll dig through the posts. Thanks!
One final questions, which I think the answer is yes from the screen shots I’ve seen…but does the ChromiumBrowser work with AllowsTransparency in the main window? I know the WPF WebBrowser control doesn’t because of the layered windows issue (not sure if MFST if going to have a workaround for that or not). All I’m trying to do is host web content within my custom chromed main window.
Something so easy that used to work pre-SP1.
Brett Burkhart // October 6, 2009 at 7:58 am |
OK, got it working. Thanks! And looks like it supports layed window transparency. So how does it do that and the WPF browser cannot?
Chris Cavanagh // October 6, 2009 at 11:48 am |
Brett – Not sure on inbuilt WebBrowser; maybe it doesn’t support windowless mode? (wild guess, probably wrong).
Fyi ChromiumBrowser/AwesomiumWrapper tweaks the rendered html slightly to make the page background color transparent.
Matthew // October 8, 2009 at 1:47 pm |
Hey Chris, I’m back to the JS callback. I can’t seem to figure this out. If you could post an update like you mentioned way back in September or possible give me an example I’d really appreciate it. -Thanks!
Matthew // October 8, 2009 at 1:57 pm |
Regarding the above post i’ve tried this…
In the WebBrowser.cs class in the InitWebView method I’ve added
webViewListener.Callback += delegate(string url, JSArguments args)
{
if (CallbackFired != null)
{
Dispatcher.BeginInvoke(
(Action)delegate { CallbackFired(this, new CallbackEventArgs(url, args)); },
DispatcherPriority.Normal);
}
};
And then in the test app I do…
InitializeComponent();
browser.Source = Settings.Default.DefaultUrl;
browser.CallbackFired += new EventHandler(browser_CallbackFired);
void browser_CallbackFired(object sender, Cjc.ChromiumBrowser.WebBrowser.CallbackEventArgs e)
{
MessageBox.Show(e.Url);
}
But no where do I call .SetCallback(); I don’t see this method exposed at all. Any ideas? (Sorry if the code paste is bad)
Matthew // October 8, 2009 at 4:17 pm |
Nevermind, I got it!
Matthew // October 8, 2009 at 5:44 pm |
Chris, So i have the callback firing but now it seems impossible to get the arguments passed to JSArguments. I tried doing something like std::string value = args[0].toString(); in the wrappers OnCallback method but no go. Any ideas? (Sorry for so many posts!)
Chris Cavanagh // October 9, 2009 at 12:28 am |
Matthew – You’ve uncovered my shameful lack of testing
I’ve fixed the (many) bugs with callback (and implemented missing methods like ExecuteJavascript) and updated the source on CodePlex. Here’s an example of how you might use a callback:
browser.Initialized += delegate { browser.SetCallback( “myCallback” ); };
browser.Callback += delegate( object sender, Cjc.ChromiumBrowser.WebBrowser.CallbackEventArgs args )
{
var test = args.Arguments.Select( a => a.ToString() ).ToArray();
….
};
Then in your javascript, you can invoke your callback method on the “Client” object like this:
Client.myCallback( “arg1″, “arg2″, 42 );
Hope this helps!
Chris Cavanagh // October 9, 2009 at 12:35 am |
@Lehel / @Wrapper Issue – Hopefully the ExecuteJavascript & Callback problems you had are now fixed
Matthew // October 9, 2009 at 12:52 am |
Chris, you are the man!! Thanks so much!
Chris Cavanagh // October 9, 2009 at 1:27 am |
Matthew – Just published another fix; ExecuteJavascriptWithResult should now work (and return a result as expected)
Eoin O'Meara // October 15, 2009 at 3:53 pm |
Chris,
I would like to use the Google Earth Plugin in your WPF browser. Unfortunately the plugin does not recognise Chromium, only Chrome.
I propose to rebuild awesomium and chromium and hope to change the version info passed to the plugin.
Even if I do this are there other problems I am not considering as the plugin uses Qt for it’s UI.
Chris Cavanagh // October 15, 2009 at 9:12 pm |
Eoin – I’m not sure if it’d work or not. Awesomium works great with Silverlight and Flash (mostly), but trips up with other plugins… Adam recently released “NaviDemo 2″ based on the latest Awesomium version (1.5). You could try some sites in that in see if plugin support has improved.
Hope this helps!
Matthew // October 16, 2009 at 4:10 pm |
Chris – So the new version you gave me works great. I’ve been using the debug version up until now. I needed to go to release, so i switched to release mode and now when i run in release mode I get an error in AwesomiumWrapper.h at line array^ argArray = gcnew array( args.size() ); in method OnCallback with the error “Arithmetic operation resulted in an overflow.” however if i switch back to debug this error does not occur. Any ideas?
Chris Cavanagh // October 16, 2009 at 5:08 pm |
Matther – Check all your project settings are same/similar for Debug & Release builds (including things like targeting x86)… Let me know if that helps
Matthew // October 19, 2009 at 11:17 am |
Chris, I have checked the settings and everything is good. I’ve even downloaded the latest version and did not modify the project at all and release build still gives the same overflow error. Any chance you might be willing to take a look at my solution? Thanks!
Chris Cavanagh // October 19, 2009 at 11:21 am |
Hi Matt – Go ahead and mail me some code ([something descriptive] at chriscavanagh.com).
Matthew // October 20, 2009 at 3:04 pm |
Chris – Just wanted to make sure you got my email with code attachments? Thanks!
Bogomir // October 29, 2009 at 2:30 pm |
Hi,
many thanks to you Chris for creating this gorgeous WPF control. You enabled me to put a WebBrowser inside a Popup with AllowTransparency set to true.
Do you have any hints on how to downscale the displayed page? That way, that no scrollbars are needed any more. Or that the page width fits to the browsers width, to have only vertical scrollbars.
Putting a Viewbox with Stretch set to Uniform didn’t work.
What I want to achieve is a preview of the page. So it might also be more feasible to make a png snapshot of the whole page and to display it in place. Is the snapshot function already capable of an entire height snapshot?
nicolas marti // November 9, 2009 at 1:41 am |
Hi,
First thank you for your contribution, it is really impressive.
I am really new to C# so sorry if my question seems stupid:
actually the webbrowser class inherit from System.Windows.ContentControl. However the original webbrowser (as well as the one that embedded gecko) inherit System.Windows.Forms.Control.
I took a look at the code, but I must confess that I am a bit lost at how to make a webbrowser using the AwesomiumWrapper into a new WebBrowser class that inherit from System.Windows.Forms.Control
Maybe someone have some advice.
Thank you and Best Regards,
Nicolas
Chris Cavanagh // November 9, 2009 at 1:49 am |
nicolas – Short of creating a WinForms-specific WebBrowser replacement, you could try hosting this WPF WebBrowser directly using ElementHost. See here: http://www.codegod.de/webappcodegod/embedding-wpf-usercontrol-in-winforms-AID422.aspx
I’m not sure how nicely it’ll behave hosted in WinForms, but it’s probably worth a try to find out
Hope this helps!
nicolas marti // November 9, 2009 at 2:54 am |
Thank you really much.
Trying it right away!
Thanks and Regards,
Nicolas
nicolas marti // November 9, 2009 at 5:34 pm |
Hi Chris,
Just a short post to tell you that it worked fine.
Endeed ElementHost was the solution (and a pretty nice trick).
Thank you and best regards,
Nicolas
Bogomir // November 10, 2009 at 7:02 pm |
Hi,
does anybody know, how I can prevent the Webbrowser control from displaying ScrollBars when it’s to small to display the whole HTML?
Chris Cavanagh // November 10, 2009 at 9:03 pm |
Bogomir – Currently the only way [I'm aware of] is to make the control much larger and put it in your own ScrollViewer (or if you use AwesomiumWrapper directly you’ll have a bit more control). The problem there is knowing how big a bitmap to use (plus the bigger it is, the slower rendering will be etc). Ideally Awesomium/Chromium would report its current virtual page size and allow disabling of its scroll bars, but currently it doesn’t.
L // November 20, 2009 at 3:58 am |
Hello,
firstly I want to thank you for this awesome control, I have it hosted in an element host in a windows form. My question is, has anyone had a problem with the control using too much cpu? In slower machines it takes up to 30% maybe more.
Thank you and best regards.
Uwe // November 20, 2009 at 4:31 am |
Is there a chance to modify your code to run it as a replacement for the WebBrowser control and use it exclusively in Windows Forms 2.0?
If you tell me “yes” and it is possible in a reasonable time span, I will take a deeper look and try to move it back to .NET 2.0.
Tobias // November 20, 2009 at 6:02 am |
Hi,
is it possible to remove the vertical scroll bar from the browser control?
We plan to put 2 Textboxes and the web browser control in a vertical StackPanel. This StackPanel has an own ScrollViewer, so the user should scroll down all content using the ScrollViewers scrollbar – the scrollbar within the browser control should be removed (the control should render the full content – the user will bring it into the view when scrolling down).
Is this possible?
Bye,
Tobias
Chris Cavanagh // November 20, 2009 at 9:16 am |
Uwe – If .NET 3.5 is installed on the target machine, the simplest option would be to host this [WPF] WebBrowser control inside Windows Forms. Alternatively you could create a native WinForms control that uses the AwesomiumWrapper component (this is what the WebBrowser uses internally). If .NET 3.5 isn’t available at all, you might need to change/rewrite Awesomium wrapper to use regular p/invoke instead of C++/CLI.
Fyi I’m kicking round the idea of a managed version of Awesomium with a minimal amount of C++ in it (just a thin C++/CLI wrapper around Chromium itself).
Chris Cavanagh // November 20, 2009 at 9:20 am |
L – Are you seeing this behavior with the ClickOnce demo, or just when hosting the control yourself? If you’re hosting it, make sure AllowAsyncRendering=false. While that setting has its uses, it’s currently less efficient than synchromous rendering.
Does the high CPU usage occur on all sites? Also, it would be helpful if you could try the same thing with “NaviDemo 2″ (a native XNA app based directly on Awesomium – http://princeofcode.com/blog/?p=374). and let me know if it performs better or not.
Chris Cavanagh // November 20, 2009 at 9:25 am |
Tobias – Currently the only way to achieve this is tell Awesomium to render to a bitmap that’s larger than the view size. Obviously this is only practical if you can determine a maximum page size to allocate, which is often difficult. Ideally Awesomium could tell us its current virtual page size, but currently it doesn’t
Maybe Awesomium 1.5 will have some support for this scenario. Alternatively if we go ahead with a managed version of Awesomium, this is something that could be taken into consideration from the start.
L // November 23, 2009 at 6:53 am |
Thank you for your reply, I am not seeing the same performance issues with the click once demo. I am thinking that I see this in my app because I used the control to display flash..I will test more and post if I have anything new.
I tried NaviDemo 2 and had almost the same amount of cpu load, but its a 3d app its bound to use more resources so I can’t really come to any conclusion. Also the AllowAsyncRendering property..I can’t find it,I am hosting in a regular windows form maybe that’s why.
Thank you, L.
Eric Grover // November 23, 2009 at 3:22 pm |
Hey Chris,
Great work! Thanks for getting us a real wpf browser.
Any plans to port this to 4.0 any time soon? I tried to compile in 4.0 beta 2, but it doesn’t work (and I haven’t had time to debug yet to see what exactly is going on).
Chris Cavanagh // November 23, 2009 at 3:35 pm |
Eric – Until it’s updated, check out the workaround mentioned in Sacha Barber’s post: http://sachabarber.net/?p=597
Hope this helps!