C# WinForm 最大化、最小化、關閉按鈕事件的攔截
阿新 • • 發佈:2019-01-27
private int WM_SYSCOMMAND = 0x112; private long SC_MAXIMIZE = 0xF030; private long SC_MINIMIZE = 0xF020; private long SC_CLOSE = 0xF060; protected override void WndProc(ref Message m) { if (m.Msg == WM_SYSCOMMAND) { if (m.WParam.ToInt64() == SC_MAXIMIZE) { //MessageBox.Show("MAXIMIZE "); return; } if (m.WParam.ToInt64() == SC_MINIMIZE) { //MessageBox.Show("MINIMIZE "); return; } if (m.WParam.ToInt64() == SC_CLOSE) { //MessageBox.Show("CLOSE "); return; } } base.WndProc(ref m); }