Using cefglue in WPF Application

2,112 views
Skip to first unread message

Mathias Bauer

unread,
Sep 29, 2011, 4:42:47 AM9/29/11
to cef...@googlegroups.com
Did anyone use cefglue successfully in a WPF application?
Is it possible?

Dmitry Azaraev

unread,
Sep 29, 2011, 4:50:52 AM9/29/11
to cef...@googlegroups.com
You can try:
a) use winfrom host control and use winforms control
b) you can try implement native wpf control, using cef's disabled window rendering feature. but as i know, this is have some performance penalties, due to WPF bug when it invalidate full rect, instead of invalidating only dirty rect.

I do not investigate both ways personality, may be someone else can say more.

On Thu, Sep 29, 2011 at 11:42 AM, Mathias Bauer <mathia...@gmx.net> wrote:
Did anyone use cefglue successfully in a WPF application?
Is it possible?



--
Best regards,
   Dmitry                             mailto:fdd...@gmail.com

Benjamin Eidelman

unread,
Sep 29, 2011, 9:10:00 PM9/29/11
to cef...@googlegroups.com
I'm using the WinForms control in a WPF application using the WindowsFormsHost control (thats the WPF control that allows you to embed a winforms control), it's working perfectly.
But if anyone is interested in developing a pure WPF control it will be great, I have checked the code and it doesn't look too hard to do.

Mathias Bauer

unread,
Sep 30, 2011, 8:44:33 AM9/30/11
to cef...@googlegroups.com
Thanks for the replies - I used WindowsFormsHost now and didn't see any problems so far. Time will tell what I overlooked in the first place. :-)

weezelboy

unread,
Nov 25, 2011, 6:32:10 PM11/25/11
to cef...@googlegroups.com
For my application I require a native WPF control since we utilize transparency. Does the disabled window rendering feature provide access to a raw frame buffer? 

Dmitry Azaraev

unread,
Nov 26, 2011, 5:32:26 AM11/26/11
to cef...@googlegroups.com
Yes, it does in cef manner. Also, afaik, transparency supported by CEF for windows.
I'm never use it in CefGlue, so may be little fixes can be required.

On Sat, Nov 26, 2011 at 1:32 AM, weezelboy <mti...@gmail.com> wrote:
For my application I require a native WPF control since we utilize transparency. Does the disabled window rendering feature provide access to a raw frame buffer? 



weezelboy

unread,
Nov 26, 2011, 12:51:02 PM11/26/11
to cef...@googlegroups.com
Thanks Dmitry, there's alot of code here - can you point me in the right direction to get started? Should I focus my attention on the CefBrowser class or maybe the CefWebBrowser?

It looks like GetImage in CefBrowser will get me the frame buffer. Is there a callback for when updates occur on the frame buffer or should I just poll on some interval?

Dmitry Azaraev

unread,
Nov 26, 2011, 4:23:24 PM11/26/11
to cef...@googlegroups.com
CefBrowser it is just a wrapper around CEF's CefBrowser class, it contains only some control methods.
To get notifications, you must set in CefClient CefRenderHandler -> it contains OnPaint method.
So you need extend CefWebBrowser / WebBrowserCore / add render handler implementation etc.
Feel free to change what you need.

You also may be find helpful CefSharp project, it will already contains wpf implementations (it implemented in C++/CLI). Check sources at http://github.com/ataranto/CefSharp , and contact to ataranto for binaries. I'm don't know current status of CefSharp, but about year ago it was be impossible use it without recompiling CEF.


On Sat, Nov 26, 2011 at 7:51 PM, weezelboy <mti...@gmail.com> wrote:
Thanks Dmitry, there's alot of code here - can you point me in the right direction to get started? Should I focus my attention on the CefBrowser class or maybe the CefWebBrowser?

It looks like GetImage in CefBrowser will get me the frame buffer. Is there a callback for when updates occur on the frame buffer or should I just poll on some interval?




Sébastien Frippiat

unread,
Jul 3, 2012, 4:06:16 AM7/3/12
to cef...@googlegroups.com
Hello.

I am trying to use cefglue in a WPF application but it doesn't seem to work for me: instead of the web content, I get a blank control.

Here is what I do:
- Create a WindowsFormHost control on my window
- In my window constructor, I create a new instance of CefWebBrowser (with a StartUrl) and assign it to the WindowsFormHost control Child property

When I display my form (which is not the main form: the form is opened through a context menu of a shell notify icon (in the lower right corner of the Windows taskbar), I get a window with a blank control in it and the control's mouse cursor is the smaller arrow with the small hourglass. It seems it doesn't get all the messages / events it requires. But I don't know what to do.

I noticed that if I change CefSettings.SingleProcess, it works, but the doc says it is not a very good idea to set it to true so I am not very keen on using that as a solution.

Here is my initialization code:
            try
            {
                CefRuntime.Load();
            }
            catch (DllNotFoundException ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                return 1;
            }
            catch (CefVersionMismatchException ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                return 2;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                return 3;
            }

            var cef_args = new CefMainArgs(new string[0]);
            var cef_app = new KiClientCefApp();
            var cef_exit_code = CefRuntime.ExecuteProcess(cef_args, cef_app);
            if (cef_exit_code != -1)
                return cef_exit_code;

            var cef_settings = new CefSettings
            {
                SingleProcess = false,
                MultiThreadedMessageLoop = true,
                LogSeverity = CefLogSeverity.Info,
                LogFile = Path.Combine(Path.GetDirectoryName(Log.LogFileName), "CefGlue.log")
            };



Does anybody have an idea about that or at least a sample WPF application (C#) ?

Thanks,
Sebastien

Dmitry Azaraev

unread,
Jul 3, 2012, 4:12:56 AM7/3/12
to cef...@googlegroups.com
Looks like problem with message loop or child process doesn't started.
What version you use?
Can you provide minimal reproduction sample?
Message has been deleted

Sébastien Frippiat

unread,
Jul 3, 2012, 7:38:37 AM7/3/12
to cef...@googlegroups.com
Hello.

Problem is now solved. It was due to child processes not being correctly handled. I had to read a bit more on the documentation to really understand how these child processes were working. Precisely, I was ignoring process command line arguments while they had to be passed to Cef. On top of that, the process must do something different when launched as a subprocess (my main process was doing some initialization before initializing Cef and that code had some checks that prevents the application to run twice).

Also, it seems that using SingleProcess=false doesn't work when debugging with Visual Studio (should be related to Visual Studio using a executable called project_exe.vshost.exe instead of project_exe.exe).

Anyway, thank you very much for the library as well as for your quick answers.
Sebastien

Dmitry Azaraev

unread,
Jul 3, 2012, 8:24:29 AM7/3/12
to cef...@googlegroups.com
> Also, it seems that using SingleProcess=false doesn't work when debugging with Visual Studio (should be related to Visual Studio using a 
> executable called project_exe.vshost.exe instead of project_exe.exe).
You can use little workaround for this: set CefSettings.BrowserSubprocessPath to you executable (not vshost), - and then you can debug browser process. Also single process mode also can be used for debug.

Carlos Lozano

unread,
Dec 12, 2012, 6:24:37 PM12/12/12
to cef...@googlegroups.com
Has anyone tried any Transforms (Rotate, Scale, etc) on CefGlue running within the WindowsFormsHost in a WPF application?

Dmitry Azaraev

unread,
Dec 13, 2012, 6:58:47 AM12/13/12
to cef...@googlegroups.com
To make transformations work, it needed to be off-screen rendering implemeted in CEF (now it have some support around this without GPU accelleration on windows) and making true wpf control.


On Thu, Dec 13, 2012 at 1:24 AM, Carlos Lozano <car...@adaptiveware.eu> wrote:
Has anyone tried any Transforms (Rotate, Scale, etc) on CefGlue running within the WindowsFormsHost in a WPF application?



--
Best regards,
   Dmitry

Sébastien Frippiat

unread,
Dec 14, 2012, 3:36:01 AM12/14/12
to cef...@googlegroups.com, dmitry....@gmail.com
Yes, you can try anything you want, it won't work because the WindowsFormsHost control has a lot of limitations.

Offscreen rendering is somewhat limited in CEF3 though.

Mat

unread,
Mar 6, 2013, 5:29:05 AM3/6/13
to cef...@googlegroups.com, benj...@gmail.com
I also try to work with WPF and CefWebbrowser and i am facing a problem , described on another thread in this group  ( https://groups.google.com/forum/?fromgroups=#!topic/cefglue/3yQ9Fhkt0Nk ) . Any idea bout the issue?Please comment on that discussion if you hav some ideas
Reply all
Reply to author
Forward
0 new messages