restore standard window controls, minimize-to-tray, close-exits
- Restore default FormBorderStyle (resizable with min/max/close buttons) - Minimize button hides to tray (WindowState=Minimized -> Hide()) - Close button and tray Exit both call Shutdown() then close normally - Tray Show/DoubleClick restores window from tray
This commit is contained in:
@@ -17,9 +17,6 @@ public partial class MainForm : Form
|
||||
Text = "gatuna";
|
||||
Width = 520;
|
||||
Height = 380;
|
||||
FormBorderStyle = FormBorderStyle.FixedSingle;
|
||||
MaximizeBox = false;
|
||||
MinimizeBox = false;
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
InitializeComponents();
|
||||
|
||||
@@ -146,14 +143,19 @@ public partial class MainForm : Form
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
if (WindowState == FormWindowState.Minimized)
|
||||
{
|
||||
Hide();
|
||||
WindowState = FormWindowState.Normal;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnFormClosing(FormClosingEventArgs e)
|
||||
{
|
||||
if (e.CloseReason == CloseReason.UserClosing)
|
||||
{
|
||||
e.Cancel = true;
|
||||
Hide();
|
||||
return;
|
||||
}
|
||||
Shutdown();
|
||||
base.OnFormClosing(e);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user