Skip to content
This repository has been archived by the owner on Oct 12, 2021. It is now read-only.

Upgrade to CefGlue v68 and CefSharp v67

softoille@gmail.com edited this page Nov 29, 2019 · 1 revision

Please Note!

*** For note on more recent versions please see Upgrade to CefGlue v70 and CefSharp v71.

Prior to upgrade of CefGlue v68 and CefSharp v67, Chromely on Windows uses the "blackbox" approach to Winapi window creation - see here. This approach encapsulates the window creation and details are hidden.

However since upgrading to CefGlue v68 and the removal of SingleProcess option see 1 and 2, the "blackbox" approach creates a separate window besides the main window. Looks like the MultiProcess option is not in sync with the "blackbox" approach. As a result, Chromely Winapi will now use the Win32 approach windows creation see here. This way there is a better control on when the browser and actual window are created.

As a result the way Chromely is created will change. For newer approach, please see the Demo Projects. Below the differences will be highlighted.

Getting started with CefGlue prio to version 68

class Program
{
   static int Main(string[] args)
   {
      var startUrl = "https://google.com";

      var config = ChromelyConfiguration
                     .Create()
                     .WitAppArgs(args)
                     .WithHostSize(1000, 600)
                     .WithStartUrl(startUrl);

     var factory = WinapiHostFactory.Init();
     using (var window = factory.CreateWindow(() => new CefGlueBrowserHost(config),
           "chromely", constructionParams: new FrameWindowConstructionParams()))
      {
         window.SetSize(config.HostWidth, config.HostHeight);
         window.CenterToScreen();
         window.Show();
         return new EventLoop().Run(window);
     }
  }
}
- Creates Chromely window of size 1000 x 600 pixels.
- Sets the window title to "chromely"
- Sets start url to "https://google.com"
- Centers the window 

Getting started with CefGlue from version 68

class Program
{
   static int Main(string[] args)
   {
      var startUrl = "https://google.com";

      var config = ChromelyConfiguration
                      .Create()
                      .WithHostMode(WindowState.Normal, true)
                      .WithHostTitle("chromely")
                      .WithHostIconFile("chromely.ico")
                      .WitAppArgs(args)
                      .WithHostSize(1000, 600)
                      .WithStartUrl(startUrl);

      using (var window = new CefGlueBrowserWindow(config))
      {
         return window.Run(args);
      }
  }
}
- Creates Chromely window of size 1000 x 600 pixels.
- Sets the window title to "chromely"
- Sets start url to "https://google.com"
- Centers the window 

Getting started with CefSharp prio to version 67

class Program
{
   static int Main(string[] args)
   {
      var startUrl = "https://google.com";

      var config = ChromelyConfiguration
                     .Create()
                     .WithAppArgs(args)
                     .WithHostSize(1000, 600)
                     .WithStartUrl(startUrl);

     var factory = WinapiHostFactory.Init();
     using (var window = factory.CreateWindow(() => new CefSharpBrowserHost(config),
           "chromely", constructionParams: new FrameWindowConstructionParams()))
      {
         window.SetSize(config.HostWidth, config.HostHeight);
         window.CenterToScreen();
         window.Show();
         return new EventLoop().Run(window);
     }
  }
}
- Creates Chromely window of size 1000 x 600 pixels.
- Sets the window title to "chromely"
- Sets start url to "https://google.com"
- Centers the window 

Getting started with CefSharp from version 67

class Program
{
   static int Main(string[] args)
   {
      var startUrl = "https://google.com";

      var config = ChromelyConfiguration
                      .Create()
                      .WithHostMode(WindowState.Normal, true)
                      .WithHostTitle("chromely")
                      .WithHostIconFile("chromely.ico")
                      .WitAppArgs(args)
                      .WithHostSize(1000, 600)
                      .WithStartUrl(startUrl);

      using (var window = new CefSharpBrowserWindow(config))
      {
         return window.Run(args);
      }
  }
}
- Creates Chromely window of size 1000 x 600 pixels.
- Sets the window title to "chromely"
- Sets start url to "https://google.com"
- Centers the window 
Clone this wiki locally