Modeless dialog in WindowsForms application not rendering

Having problems with building or using the CefGlue .NET/Mono binding? Ask your questions here.

Moderator: fddima

Modeless dialog in WindowsForms application not rendering

Postby smeyer » Tue Feb 11, 2014 8:48 am

I am trying to replace the Windows.Forms.WebBrowser within a MDI WinForms application. I have the CefGlue code integrated with my application but the browser dialog doesn't load or render the document.

I began with the WinForms example in the distribution and got that working. Next, I built a minimal version of that as a separate solution, removing everything but the CefGlue; CefGlue.Demo; and CefGlue.Demo.Winforms assemblies. That works fine. I combined the CefGlue.Demo and CefGlue.Demo.Winforms assemblies into one and it runs, displaying the desired document. Finally I took the combined CefGlue.Demo and CefGlue.Demo.Winforms assemblies and added it into one of my UI assemblies as its own folder. Setting all the references and copying over all the .dlls and other files from the example solution bin directory seems to have got all the inclusions lined up.

Running my original applicaion combined with the CefGlue WinForms Demo intially got the error:
System.InvalidOperationException: Starting a second message loop on a single thread is not a valid operation. Use Form.ShowDialog instead.
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run()
at Xilium.CefGlue.Demo.DemoAppImpl.PlatformRunMessageLoop()


So I changed the DemoAppImpl.PlatformRunMessageLoop() call to ((MainViewImpl)_mainView).Show() (I need the browser to open in a modeless dialog to allow continued interaction with the main app or with the browser.) and moved the dispose and shutdown code into DemoApp's Quit() method. Everybody seemed happy.

When the CefGlue code is run, the browser.LoadingStateChanged event handler gets called but no other handler defined within MainViewImpl's NewTab() gets called, not browser.AddressChanged, nor browser.TargetUrlChanged etc. The tab title is set correctly but the tab page's content stays empty white and the cursor just spins and spins. I have disabled the solution's Visual Studio Hosting process and after I changed that I started getting two more of my main app windows popping up.

cef.log:
...
[0211/075743:VERBOSE1:pref_proxy_config_tracker_impl.cc(148)] 06C46780: set chrome proxy config service to 06C46640
[0211/075743:VERBOSE1:pref_proxy_config_tracker_impl.cc(274)] 06C46780: Done pushing proxy to UpdateProxyConfig
[0211/075755:VERBOSE1:proxy_service.cc(1135)] Failed configuring with PAC script, falling-back to manual proxy servers.

...

Is this a proxy configuration issue as the log hints?
Is the message loop begun by the Form.Show call sufficient for starting the spawned browser dialog's messaging?
Should the CefGlue browser form code be part of the UI assembly or should it remain a separate executable?

Is there any example of a main form calling the CefGlue browser in a dialog (modal or modeless) ?

VS2010 Premium, .Net 3.5
Thanks for your help.
Steven
smeyer
Newbie
 
Posts: 1
Joined: Tue Feb 11, 2014 8:02 am

Re: Modeless dialog in WindowsForms application not renderin

Postby fddima » Tue Feb 11, 2014 2:18 pm

Hi!

I'm not sure that you doing. Why you did not use WinForms control directly?
Demo application it is more about how it can be used, and everything else.

Is this a proxy configuration issue as the log hints?
Is the message loop begun by the Form.Show call sufficient for starting the spawned browser dialog's messaging?

You have proxy? Proxy are configured using PAC-script? Then probably there is issue with proxy, but probably PAC-script are wrong, and you are living with this long time. I'm did not know.

Should the CefGlue browser form code be part of the UI assembly or should it remain a separate executable?

It can do both options. I.e. in multi-process mode you can spawn same executable as main (like chrome, like demo). Or you can specify in CefSettings other executable, which will be used to spawn child processes.

Is there any example of a main form calling the CefGlue browser in a dialog (modal or modeless) ?

Yes, check Popup sample, but it is incomplete, and it did not loading anything (you should specify other load url to see anything).
So that you are must do in your's application:

1. In Program.cs (Main method) put almost all logic related to CEF. It is loads CEF, initialize it, runs message loop (via Application.Run or CEF's message loop). Also you have option to use same message loop thread, or separate message-loop for CEF windows. There is are simply and most non-problematic way.

2. Create form with control. And just show it as usual. There is nothing special exist.

And of course you should not call Application.Run twice, as you do in-first case.
fddima
Master
 
Posts: 788
Joined: Tue Dec 07, 2010 6:10 am


Return to CefGlue Forum

Who is online

Users browsing this forum: No registered users and 18 guests