
去掉如图的窗口;
public partial class FormZpenSample : Form
{
public FormZpenSample()
{
InitializeComponent();
#region 托盘处理
//隐藏ui
this.WindowState = FormWindowState.Minimized;
//隐藏任务栏区图标
this.ShowInTaskbar = false;
//不显示
this.Hide();
//图标显示在托盘区
notifyIcon1.Visible = true;
//双击展示
notifyIcon1.DoubleClick += (sender, evegs) =>
{
this.Show();
};
//去掉最小化后左下角窗口
this.Resize += (sender, even) =>
{
var formCurrent = sender as Form;
if (formCurrent != null && formCurrent.WindowState == FormWindowState.Minimized)
{
formCurrent.Hide();
}
else if (formCurrent != null && formCurrent.WindowState == FormWindowState.Normal)
{
formCurrent.Show();
}
};
#endregion
}
}
该代码示例展示了如何将WindowsForms应用程序窗口最小化到系统托盘区域,并在双击通知图标时重新显示窗口。通过设置`WindowState`和`ShowInTaskbar`属性来隐藏UI和任务栏图标,同时利用`NotifyIcon`组件处理用户交互。
2456

被折叠的 条评论
为什么被折叠?



