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)) { // 点击winform右上关闭按钮 // 加入想要的逻辑处理 MessageBox.Show("弹出Form3窗体"); Form3 form = new Form3(); form.Show(); //return;//阻止了窗体关闭 } base.WndProc(ref msg); }