Skip to content

Commit

Permalink
WinForms Example - Load Url after browser initialized
Browse files Browse the repository at this point in the history
Temp workaround for a bug where the address passed into the constructor isn't always loading
  • Loading branch information
amaitland committed Jan 25, 2018
1 parent c062e8b commit 562bfee
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion CefSharp.MinimalExample.WinForms/BrowserForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public BrowserForm()
Text = "CefSharp";
WindowState = FormWindowState.Maximized;

browser = new ChromiumWebBrowser("www.google.com")
browser = new ChromiumWebBrowser()
{
Dock = DockStyle.Fill,
};
Expand All @@ -31,12 +31,21 @@ public BrowserForm()
browser.StatusMessage += OnBrowserStatusMessage;
browser.TitleChanged += OnBrowserTitleChanged;
browser.AddressChanged += OnBrowserAddressChanged;
browser.IsBrowserInitializedChanged += OnIsBrowserInitializedChanged;

var bitness = Environment.Is64BitProcess ? "x64" : "x86";
var version = String.Format("Chromium: {0}, CEF: {1}, CefSharp: {2}, Environment: {3}", Cef.ChromiumVersion, Cef.CefVersion, Cef.CefSharpVersion, bitness);
DisplayOutput(version);
}

private void OnIsBrowserInitializedChanged(object sender, IsBrowserInitializedChangedEventArgs e)
{
if(e.IsBrowserInitialized)
{
browser.Load("www.google.com");
}
}

private void OnBrowserConsoleMessage(object sender, ConsoleMessageEventArgs args)
{
DisplayOutput(string.Format("Line: {0}, Source: {1}, Message: {2}", args.Line, args.Source, args.Message));
Expand Down

0 comments on commit 562bfee

Please sign in to comment.