Open MartinRothschink opened 6 years ago
I'm still trying to create a tray application with a hidden main window. Now I noticed that I can't prevent the closing of a hidden main window.
OnClosing: e.Cancel = true should stop closing a window, regardless of its visibility.
If window is invisible, window is closed
using System; using Eto.Forms; using Eto.Drawing; namespace EtoTrayApp { using System.ComponentModel; public partial class MainForm : Form { private bool _startup = true; private TrayIndicator _tray; public MainForm() { Title = "My Eto Form"; ClientSize = new Size(200, 200); _tray = new TrayIndicator { Image = Eto.Drawing.Icon.FromResource("EtoTrayApp.error.ico"), Menu = new ContextMenu { Items = { new ButtonMenuItem {Text = "Quit", Command = new Command((s, e) => Application.Instance.Quit())} } } }; ShowInTaskbar = false; _tray.Visible = true; } protected override void OnClosing(CancelEventArgs e) { base.OnClosing(e); e.Cancel = true; } protected override void OnClosed(EventArgs e) { base.OnClosed(e); _tray.Dispose(); } protected override void OnShown(EventArgs e) { base.OnShown(e); if (_startup) { // change this to false to show the issue Visible = true; _startup = false; } } } }
This works on MAC and GTK as expected.
I'm still trying to create a tray application with a hidden main window. Now I noticed that I can't prevent the closing of a hidden main window.
Expected Behavior
OnClosing: e.Cancel = true should stop closing a window, regardless of its visibility.
Actual Behavior
If window is invisible, window is closed
Steps to Reproduce the Problem
Code that Demonstrates the Problem
Specifications