07菜單及右下角小圖標的練習,07菜單圖標
private void 退出ToolStripMenuItem_Click(object sender, EventArgs e) //退出菜單方法
{
//this.Close();
Application.Exit();//建議使用該關閉語句
}
private void timer1_Tick(object sender, EventArgs e) //時間方法
{
toolStripStatusLabel1.Text = DateTime.Now.ToString();
}
private void Form1_Resize(object sender, EventArgs e)//窗口最大最小改變後產生的效果
{
if (this.WindowState == FormWindowState.Minimized)
{
notifyIcon1.Visible = true;
this.Visible = false;
}
else
{
notifyIcon1.Visible = false;
this.Visible = true;
}
}
private void Form1_Load(object sender, EventArgs e)
{
//if (this.WindowState == FormWindowState.Minimized)
//{
// ShowInTaskbar = false;
//}
}
//private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
//{
// this.Visible = true;
// this.WindowState = FormWindowState.Normal;
//}
private void notifyIcon1_DoubleClick(object sender, EventArgs e) //右下角小圖標相關設定
{
this.Visible = true;
this.WindowState = FormWindowState.Normal;
}
private void 顯示ToolStripMenuItem_Click(object sender, EventArgs e) //雙擊右下角圖標顯示程序窗口
{
notifyIcon1_DoubleClick(sender, e);
}