c#中的窗口关闭事件如何活

来源:互联网 发布:java中的initcause方法 编辑:程序博客网 时间:2024/05/19 07:42
  //关闭事件
        protected override void WndProc(ref Message msg)
        {
            const int WM_SYSCOMMAND = 0x0112;
            const int SC_CLOSE = 0xF060;


            if (msg.Msg == WM_SYSCOMMAND && ((int)msg.WParam == SC_CLOSE))
            {
                if (MessageBox.Show("是结束程序吗?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    if (uin_wx == null || uin_wx.Count == 0)
                        return;
                    this.Close();
                    ArrayList values = new ArrayList(uin_wx.Values);
                    foreach (WxBean bean in values)
                    {
                        bean.logout();//登出所有微信号
                    }
                }
                return;
            }
            base.WndProc(ref msg);
        }
0 0
原创粉丝点击