刚做了一个很小的邮件计费小系统,但是关闭后直接在开始->程序那块打开,怎么让它一直在系统托盘里面呢,即使最小化和关闭都在系统托盘里面嗯?,还有一个就是,我在窗口上还放了网页的链接,点开之后窗口就给关闭了,请大家帮忙下,问题要是简单了,请大家不要BS哦~因为偶很菜的哦~希望大虾们来帮忙看看

解决方案 »

  1.   

    添加一个NotifyIcon控件,给它设定一个Icon 
    然后加代码: private   void   notifyIcon1_MouseDown(object   sender,   MouseEventArgs   e) 

            this.Show(); 

    //还有关闭事件
    void   Formxx_Resize(object   sender,   System.EventArgs   e) 

            if   (this.WindowState   ==   FormWindowState.Minimized) 
                    this.Hide(); 
    }
      

  2.   

    从别处看的,主要是重载OnFormClosing这个事件,在这个事件了里把窗体的状态设置成最小化
    详细的看这个吧http://hi.baidu.com/nash635/blog/item/10cd20135696ff866438dba8.html
      

  3.   

    需要给notifyIcon加个双击事件
    private void notifyIcon1_DoubleClick(object sender, EventArgs e)
            {
                this.Visible = true;
                this.WindowState = FormWindowState.Normal;
            }
      

  4.   

    另外最小化:
    private void Form1_FormClosing(object sender, FormClosingEventArgs e)
            {
                   this.WindowState = FormWindowState.Minimized;
                    this.Visible = false;
            }        private void Form1_Resize(object sender, EventArgs e)
            {
                if (this.WindowState == FormWindowState.Minimized)
                {
                    this.Visible = false;
                }
            }
    网页那个是不是没有指定target,如是,指定为target=_blank
      

  5.   

    如何实现窗体关闭时,最下化到托盘拖一个notifyIcon到窗体上,然后设置:
    this.notifyIcon1.BalloonTipText = "应用程序最小化在这里!";
    this.notifyIcon1.BalloonTipTitle = "提示信息";
    this.notifyIcon1.Icon = this.Icon;this.notifyIcon1.MouseClick += new MouseEventHandler(notifyIcon1_MouseClick);
    private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
    {
        this.Show();
    }private void DataGridViewCustomPaint_SizeChanged(object sender, EventArgs e)
    {
        if (this.WindowState == FormWindowState.Minimized)
        {
            this.Hide();
        }
    }
    如果要实现关闭窗体时不是退出程序,而是最小化到托盘,需要重写窗口过程:
    protected override void WndProc(ref Message m)
    {
      if ((m.Msg == 0x112) && (((int)m.WParam) == 0xf060))
      {
      this.notifyIcon1.ShowBalloonTip(10);
      base.Hide();
      }
      else
      {
      base.WndProc(ref m);
      }
    }
      

  6.   


    8楼的兄弟,可以实现关闭了,但是提示:this.notifyIcon1.ShowBalloonTip(10);这个什么气球状提示文本必须有非空的值
    这个看了下MSDN没有看懂哦~
      

  7.   


    this.notifyIcon1.BalloonTipText = "不要为空";