K Ken Tucker [MVP] Oct 8, 2003 #2 Hi, Override WndProc on the form. Here is a VB.Net example. Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) Const WM_SYSCOMMAND = &H112 Const SC_CLOSE = &HF060& If m.Msg = WM_SYSCOMMAND Then ' Do something ElseIf m.Msg = SC_CLOSE Then ' Do something else End If ' Need to call the mybase.wndproc or the app wont work MyBase.WndProc(m) End Sub Ken
Hi, Override WndProc on the form. Here is a VB.Net example. Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) Const WM_SYSCOMMAND = &H112 Const SC_CLOSE = &HF060& If m.Msg = WM_SYSCOMMAND Then ' Do something ElseIf m.Msg = SC_CLOSE Then ' Do something else End If ' Need to call the mybase.wndproc or the app wont work MyBase.WndProc(m) End Sub Ken
M Mr.Tickle Oct 8, 2003 #3 I find it stupid that the Form doesnt have an event for the system menu while win32 has, to me this is a loss of functionality.
I find it stupid that the Form doesnt have an event for the system menu while win32 has, to me this is a loss of functionality.
M Mr.Tickle Oct 8, 2003 #4 in win32 its case WM_SYSCOMMAND: { if (LOWORD(wParam) == SC_CLOSE) { // handle close here } break; } so how come m.Msg has SC_CLOSE? that looks odd, shoudlnt it be in m.WParam ?
in win32 its case WM_SYSCOMMAND: { if (LOWORD(wParam) == SC_CLOSE) { // handle close here } break; } so how come m.Msg has SC_CLOSE? that looks odd, shoudlnt it be in m.WParam ?
M Mr.Tickle Oct 8, 2003 #5 // found it.. I dono why MS cant provide us with the message constants, forcing us to redefine them is just asking for problems. I always hated that about VB6. I just see it as lazyness on theyre part. protected override void WndProc(ref System.Windows.Forms.Message m) { const int WM_SYSCOMMAND = 0x112; const int SC_CLOSE = 0xf060; if (m.Msg == WM_SYSCOMMAND) { if (m.WParam.ToInt32() == SC_CLOSE) { return; } } base.WndProc(ref m); }
// found it.. I dono why MS cant provide us with the message constants, forcing us to redefine them is just asking for problems. I always hated that about VB6. I just see it as lazyness on theyre part. protected override void WndProc(ref System.Windows.Forms.Message m) { const int WM_SYSCOMMAND = 0x112; const int SC_CLOSE = 0xf060; if (m.Msg == WM_SYSCOMMAND) { if (m.WParam.ToInt32() == SC_CLOSE) { return; } } base.WndProc(ref m); }