为了窗体美观,我设置了FromborderStyle属性为none,现在当窗体显现的时候后我想让窗体的任务栏可以点击,让窗体最小化。最小化时点击窗体显现。不知道如何实现
C# 如何让窗体的任务栏图标点击能最小化窗体
- 提问者网友:记得曾经
- 2021-04-29 00:04
- 五星知识达人网友:青尢
- 2021-04-29 00:41
- 1楼网友:你哪知我潦倒为你
- 2021-04-29 03:20
public void QPan_MiniMizedToTuoPan() {
this.Hide();
this.ShowInTaskbar = false;
this.notifyIcon1.Visible = true;
} public void QPan_OpenFromTuoPan() {
this.Visible = true;
this.Show();
this.ShowInTaskbar = true;
this.WindowState = System.Windows.Forms.FormWindowState.Normal;
this.notifyIcon1.Visible = true;
}
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) { this.QPan_OpenFromTuoPan(); }
private void Form1_SizeChanged(object sender, EventArgs e) { if (this.WindowState == System.Windows.Forms.FormWindowState.Minimized) {
this.QPan_MiniMizedToTuoPan();
} }
Form1_SizeChanged是form的sizechanged事件
- 2楼网友:话散在刀尖上
- 2021-04-29 01:42
网上搜下 notifyIcon1 控件的使用,可以让winform窗体最小化到系统托盘,可以控制是否显示在任务栏,等等效果,关键代码:
鼠标悬停至托盘图标效果: