建立一個(gè) contextMenu1 上面有4個(gè)菜單項,miShowWindow,miShowIcon,miShowAll,miExit
然后設置主窗體和notifyIcon(此處實(shí)例是ni)的contextMenu為此contextMenu1,單擊菜單可以看到效果,如果最小化也要推到托盤(pán)的話(huà),可能要用到其它事件
.................................................................
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Notify
{
public partial class Notify : Form
{
public Notify()
{
InitializeComponent();
}
private void miShowWindow_Click(object sender, EventArgs e)
{
//顯示窗體
this.Visible = true;
this.ni.Visible = false;
}
private void miShowAll_Click(object sender, EventArgs e)
{
//顯示全部
this.Visible = true;
this.ni.Visible = true;
}
private void miShowIcon_Click(object sender, EventArgs e)
{
//顯示托盤(pán)
this.Visible = false;
this.ni.Visible = true;
}
private void miExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void ni_Click(object sender, EventArgs e)
{
//顯示托盤(pán)
miShowWindow_Click(sender, e);
}
}
}
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請
點(diǎn)擊舉報。