-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WinForms - Toggle Form.ShowInTaskbar causes browser reload #2042
Comments
It may be possible to handle this scenario by reparenting the browser window handle. http://www.magpcss.org/ceforum/viewtopic.php?f=6&t=10290
|
This comment has been minimized.
This comment has been minimized.
The |
Resolved with 85e3297 |
@amaitland It doesn't see to work for me. Expected: to see browser as it was protected override void OnLoad(EventArgs e)
{
if (!DesignMode)
{
browserControl = new ChromiumWebBrowser("https://blog.rthand.com/")
{
Dock = DockStyle.Fill
};
Controls.Add(browserControl);
}
base.OnLoad(e);
}
protected override async void OnClosing(CancelEventArgs e)
{
e.Cancel = true;
ShowInTaskbar = false;
WindowState = FormWindowState.Minimized;
base.OnClosing(e);
await Task.Delay(1000);
WindowState = FormWindowState.Normal;
ShowInTaskbar = true;
} |
It works with the When the |
The browser needs to be temporarily re-parented to a new control whilst the handle is destroyed and a new one created. A workaround would look something like. var parent = toolStripContainer.ContentPanel;
var tempControl = new Control();
tempControl.CreateControl();
parent.Controls.Remove(browser);
tempControl.Controls.Add(browser);
ShowInTaskbar = !ShowInTaskbar;
tempControl.Controls.Remove(browser);
parent.Controls.Add(browser);
tempControl.Dispose();
tempControl = null;
|
Use a parkingControl as a temporary parent for the CefBrowser while the handle is recreating. https://docs.microsoft.com/en-us/archive/blogs/sburke/flashback-windows-forms-parking-window Issue cefsharp#2840 should now create a new browser correctly when the MdiParent is changed, the browser state won't be persisted, I believe this is expected as detailed in the .Net Source https://referencesource.microsoft.com/#System.Windows.Forms/winforms/Managed/System/WinForms/Form.cs,1925 When toggling ShowInTaskbar when the browser is hosted in a TabControl then the handle isn't actually recreated yet the browser is effectively parked, perhaps the .Net source has some tricks we can use to further improve the case when using MdiParent Resolves cefsharp#2042
Use a parkingControl as a temporary parent for the CefBrowser while the handle is recreating. https://docs.microsoft.com/en-us/archive/blogs/sburke/flashback-windows-forms-parking-window Issue cefsharp#2840 should now create a new browser correctly when the MdiParent is changed, the browser state won't be persisted, I believe this is expected as detailed in the .Net Source https://referencesource.microsoft.com/#System.Windows.Forms/winforms/Managed/System/WinForms/Form.cs,1925 When toggling ShowInTaskbar when the browser is hosted in a TabControl then the handle isn't actually recreated yet the browser is effectively parked, perhaps the .Net source has some tricks we can use to further improve the case when using MdiParent Resolves cefsharp#2042
Use a parkingControl as a temporary parent for the CefBrowser while the handle is recreating. https://docs.microsoft.com/en-us/archive/blogs/sburke/flashback-windows-forms-parking-window Issue #2840 should now create a new browser correctly when the MdiParent is changed, the browser state won't be persisted, I believe this is expected as detailed in the .Net Source https://referencesource.microsoft.com/#System.Windows.Forms/winforms/Managed/System/WinForms/Form.cs,1925 When toggling ShowInTaskbar when the browser is hosted in a TabControl then the handle isn't actually recreated yet the browser is effectively parked, perhaps the .Net source has some tricks we can use to further improve the case when using MdiParent Resolves #2042
this.Visible = !this.Visible; |
changing the minimal example with this line
add a menu item that does:
this.ShowInTaskbar = !this.ShowInTaskbar;
causes the url to reload
Bug Report
using versions 55, 57
x86 + x64
Win10
using
WinForms
https://github.com/cefsharp/CefSharp.MinimalExample
The text was updated successfully, but these errors were encountered: