就是我想实现一个像酷狗一样的功能,单击关闭按钮时不是关闭而是把应用程序最小化到桌面

解决方案 »

  1.   

    private   void   Form_Closing(object   sender,   CancelEventArgs   e)   
      {   
      e.Cancel   =   true;   
      this.WindowState   =   FormWindowState.Minimized
      }   
      

  2.   

    用asp.net无法实现,要写winform程序
      

  3.   

           private void  Form_Closing(object sender, EventArgs e)
            {          
                if (this.WindowState == FormWindowState.Minimized) 
                { 
                    this.Visible = false; 
                    this.Icon(系统托盘图标).Visible = true; 
                } 
            }
                private void notifyIcon1_Click(object sender, System.EventArgs e) 
                { 
                    this.Visible = true; 
                    this.WindowState = FormWindowState.Normal; 
                    this.Icon.Visible = false; 
            } 
    你是要关闭还是最小化 想关闭的话在系统托盘图右健点退出吧。
      

  4.   

    private void  Form_Closing(object sender, EventArgs e) 
            {          
                if (this.WindowState == FormWindowState.Minimized) 
                { 
                    this.Visible = false; 
                    this.notifyIcon1(系统托盘图标).Visible = true; 
                } 
            } 
                private void notifyIcon1_Click(object sender, System.EventArgs e) 
                { 
                    this.Visible = true; 
                    this.WindowState = FormWindowState.Normal; 
                    this.notifyIcon1.Visible = false; 
            } 
    notifyIcon1 是个控件
      

  5.   

    Form1.cs
      public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            protected override void WndProc(ref   Message m)
            {
                const int SYSCMD = 0x0112;
                const int CLOSE = 0xF060;
                const int MINIMIZE = 0xF020;            if (m.Msg == SYSCMD && ((int)m.WParam == MINIMIZE || (int)m.WParam == CLOSE))
                {
                    //最小化到系统栏 
                    base.WindowState = FormWindowState.Minimized;
                    base.Hide();
                    return;
                }
                base.WndProc(ref   m);
            }        private void Open_Click(object sender, EventArgs e)
            {
                ShowForm();
            }        private void Exit_Click(object sender, EventArgs e)
            {
                Application.Exit();
            }        private void ShowForm()
            {
                if (!base.Visible)
                {
                    base.Show();
                }
                if (base.WindowState == FormWindowState.Minimized)
                {
                    Win32APIS.SendMessage(base.Handle, 0x112, 0xf120, 0);
                }
                base.Activate();        }
        }Win32APIS.cs
     public class Win32APIS
        {
            [DllImport("user32.dll", CharSet = CharSet.Auto)]
            public static extern int SendMessage(IntPtr hWnd, int wMsg, int wParam, int lParam);
        }
      

  6.   

    不行!
    我刚刚写的demo,实际测试过的。
      

  7.   

    发mail地址给我,我把代码发给你。