How do you display a custom message with CefSharp when JavaScript handles OnBeforeUnload? - winforms

I have implemented my own class for IJsDialogHandler for a WinForms desktop app. I want to display a custom dialog instead of the default dialog. The example from CefSharp GitHub site just says to return true to handle it myself, but that doesn't show me how to display my own dialog.
How do I display my dialog?
Do I need to also implement a LifeSpanHandler? I've seen some articles using it to know the browser is closing.

Related

WebBrowser in C# winforms lagging

I'm currently building a desktop app using C# winforms. One of the requirement is to display the client's website on a form, so I've just added a webbrowser widget.
This webpage seems to "lag" a lot, all CSS or JQuery animations seems jaggy. I tried to open the page in IE and it doesn't lag that much.
Is there any option I need to pass to the webbrowser widget to make it more faithfull ? Some double buffering, or any other kind of parameters that I could use ?

Keyboard focus problems

I am needing to use the DotNetBrowserControl inside of another application (I am an add-in in the application). The application is written in WPF and has some WinForms components.
When I try to use the WPFBrowserView in the app I can never get focus to go into the Browser Window at all (even when clicking on a the google search box for example).
When I try to use the WinformsBrowserView inside of a WindowsFormsHost control I am able to get focus into the google search box by clicking on it. However once I click focus out of the browser control (to a WPF textbox for example) I can never get Keyboard focus back into the browser (even when clicking on a textbox in the browser).
It seams I am closest on getting the WInformsBrowserView working. Does anyone have any advice on how to force focus into the browser window? Even if I could programmatically force this to happen it would be a huge help.
We have implemented force focus feature for DotNetBrowser, but it is not yet present in the current version. We plan to add it to the next version of DotNetBrowser. If you need a build with this feature present, please get in touch with us via DotNetBrowser support email, and we will provide you with a preview build.

How to get codenameone web browser component input controls references?

Does anybody know how can we get the form controls references in a web page that loaded in the CodeNameOne Web browser component?
I want to load a web page in CodeNameOne web browser component, then read or change the value of form input controls (For example TextBoxes) in the java code after pressing the submit button.
Regards,
Kasra
Its not an ideal way to work and would reduce the portability of your application. You can look at the JSObject class that represents a bridge between the JavaScript and Java sides.

Silverlight App inside WPF WebBrowser?

I have a hopefully trivial question. Currently, my company works with a rather obscure language (SyngergyDE) and we need to call a SilverLight application inside our product. Unfortunately, this obscure 3rd party language only (currently) supports the opening of WPF screens. So with that said, I thought I'd develop a small WPF user control that contains a "WebBrowser" control and navigate to the silverlight application's URI. This works fine, and I'm able to see the SL application. Here is my question - we have a "Close" button on the SL application, and when users "Click" that button, we want the window to close.
Does anyone have any suggestions on how we can communicate the "Closing of the SL App" to the WPF user control, so that the entire WPF user control closes as well?
Thanks everyone,
-Tom
Attach an event handler to the WebBrowser.Navigated event.
Have the close button in the Silverlight application use:-
HtmlPage.Window.Navigate(new Uri("about:blank", UriKind.Absolute));
When the Navigated event fires in WPF with the url "about:blank" then its time to close the control.
Use Javascript and the HTML DOM as the glue here.
For example, when the SL app close button is clicked, have Silverlight trigger some Javascript code that sets a flag, or alternately, raises some HTML document event.
The WPF control could poll that flag in the HTML + Javascript, or alternately listen for that HTML document event, then close the user control.

Display modal Silverlight popup on HTML button click

I have the following desired workflow: on HTML button click a Silverlight modal popup (dialog) must be displayed. No Silverlight content is displayed before HTML button click and no Silverlight content must be displayed after exiting from modal SL popup.
According to our customer inclination we couldn't use another technology for such popups.
Any thoughts on how to accomplish mentioned workflow?
I'm quite new to Silverlight so all the ideas are highly appreciated.
The requirement is a little unusual, but here goes...
I am assuming you have a Silverlight test project and know enough HTML/JScript to popup a window, as you tagged this question as Silverlight only.
Think of Silverlight as just another component you can put on a web page. Any web page. It can be a small control, or fill a HTML window.
In your case you want to simply put your Silverlight startup code into a html page that a popup window can show. The popup window will be triggered by JScript attached to a button.
The Silverlight startup code is usually generated for you in a HTML test webpage in your Silverlight Webproject. Copy it from there.
If you need more detailed instructions for a specific example, please provide more detail.

Resources