Created
May 16, 2019 00:52
-
-
Save tocalai/01fe6f58eb11dca6833d439291f32127 to your computer and use it in GitHub Desktop.
Demo form that use cefsharp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class DemoForm : Form | |
{ | |
public ChromiumWebBrowser ChromeBrowser; | |
// the target resource uri for browser rendering | |
private readonly string _address; | |
public DemoForm(string address) | |
{ | |
_address = address; | |
StartPosition = FormStartPosition.CenterScreen; | |
InitializeComponent(); | |
// start the browser componet | |
InitializeChromium(); | |
} | |
public void InitializeChromium() | |
{ | |
// enable high dpi support | |
Cef.EnableHighDPISupport(); | |
CefSettings settings = new CefSettings(); | |
// initialize cef with the provided settings | |
Cef.Initialize(settings); | |
// create a browser component | |
ChromeBrowser = new ChromiumWebBrowser(_address); | |
// add it to the form and fill it to the form window. | |
this.Controls.Add(ChromeBrowser); | |
ChromeBrowser.Dock = DockStyle.Fill; | |
} | |
// close the browser component | |
private void DemoForm_FormClosing(object sender, FormClosingEventArgs e) | |
{ | |
Cef.Shutdown(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment