托盘再次打开窗口时出现错误
我做了一个托盘程序,再打开程序时,能正确隐藏窗口。通过托盘打开窗口,点击窗口最小化,重新隐藏窗口,可再通过托盘显示时,窗口只能显示标题栏,这是怎么回事啊?
程序在下面:
public Form1()
{
InitializeComponent();
Initializenotifyicon();//使用托盘显示初始化
}
private void Initializenotifyicon()
{
this.MaximizeBox = false;
this.ShowInTaskbar = false;
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
this.Visible = false;
this.SizeChanged += new EventHandler(Form1_SizeChanged);
TrayIcon = new NotifyIcon();
TrayIcon.Icon = mNetTrayIcon;
TrayIcon.Text = "事件监听程序 " + "\n " + "版权:北京安图公司 ";
TrayIcon.Visible = true;
TrayIcon.Click += new System.EventHandler(this.OpenForm);
MenuItem[] mnuItms = new MenuItem[3];
mnuItms[0] = new MenuItem();
mnuItms[0].Text = "打开 ";
mnuItms[0].Click += new EventHandler(this.OpenForm);
mnuItms[0].DefaultItem = true;
mnuItms[1] = new MenuItem( "- ");
mnuItms[2] = new MenuItem();
mnuItms[2].Text = "退出系统 ";
mnuItms[2].Click += new EventHandler(this.CloseForm);
notifyiconMnu = new ContextMenu(mnuItms);