I open two forms in one time, I see a problem that both forms are flickering and the focus is switching between both. Any idea what is wrong?
The both formw should be in different display, but I can reproduce this behavior in 4K monitor as well. On this 4K display, the forms are a little covered and I see that form and formTwo are flickering. Every form want's to be on top.
In the formTwo is the web site which has an animation, when the formTwo has a focus. This animation is flickering like both forms windows.
form = new PresentationScreen("web", new Rectangle(0, 0, 1920, 1080));
form.StartPosition = FormStartPosition.Manual;
formTwo.FormBorderStyle = FormBorderStyle.None;
form.Left = 1920;
form.Top = 1080;
form.Show();
formTwo = new PresentationScreen("web", new Rectangle(0, 0, 1920, 1080));
formTwo.StartPosition = FormStartPosition.Manual;
formTwo.FormBorderStyle = FormBorderStyle.None;
formTwo.Show();
The PresentationScreen contains only one Panel with CefSharp.WinForms.ChromiumWebBrowser:
public partial class PresentationScreen : Form {
private Panel mWebPanel;
ChromiumWebBrowser chromeBrowser;
private String mCurrentWeb;
protected override CreateParams CreateParams {
get {
CreateParams handleParam = base.CreateParams;
handleParam.ExStyle |= 0x02000000;
return handleParam;
}
}
public PresentationScreen(String type, String path, Rectangle resolution) {
InitializeComponent();
mWebPanel = new Panel();
mWebPanel.Size = new Size(resolution.Width, resolution.Height);
if (string.IsNullOrEmpty(path)) {
Program.logError("[PresentationScreen] path is empty!");
return;
}
if (String.Compare(type, "web") == 0) {
mCurrentWeb = path;
webPanel.Visible = true;
Program.InitializeChromium(); //TODO vlastni object
chromeBrowser = new ChromiumWebBrowser();
chromeBrowser.MaximumSize = new Size(resolution.Width, resolution.Height);
chromeBrowser.Load(mCurrentWeb);
// Add it to the form and fill it to the form window.
webPanel.Controls.Add(chromeBrowser);
chromeBrowser.Dock = DockStyle.Fill;
}
}
public void loadWeb(String web) {
mCurrentWeb = web;
chromeBrowser.Load(web);
}
public void useWebScript(String script) {
try {
chromeBrowser.ExecuteScriptAsync(script);
} catch (Exception ex) {
Program.logError("[PresentationScreen]: " + ex.Message);
}
}
}
I am using target framework .NET 4.6