5.NotifyIcon
1.图标的变换
private void button1_Click(object sender, EventArgs e)
{
this.Hide();//隐藏
}
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.Show();双击显示
}
private void showFormToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Show();右键显示
}
private void hideFormToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Hide();右键隐藏
}
2.图标变换
private Icon oldIcon;//定义一个初始图标
private void Form1_Load(object sender, EventArgs e)
{
oldIcon = notifyIcon1.Icon;
}
private void button2_Click(object sender, EventArgs e)
{
notifyIcon1.Icon = Properties.Resources.setup;//图标变换为resource中的setup.ico
}
private void button3_Click(object sender, EventArgs e)
{
notifyIcon1.Icon = oldIcon;//变回原来的图标
}
3.右键的关联
在NotifyIcon的 ContextStrip属性为右键的ID即可。
浙公网安备 33010602011771号