// When the user attempts to close the form, this code hides the form instead of closing it private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.UserClosing) { e.Cancel = true; Hide(); } } // Clicking the NotifyIcon will restore the form to its normal state private void uxNotifyIcon_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { Show(); WindowState = FormWindowState.Normal; Activate(); } } // This is the code behind the "Quit" item on the NotifyIcon's context menu private void uxQuitMenuItem_Click(object sender, EventArgs e) { Application.Exit(); }
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.