John,
When u exit the application either by pressing X button or from menu,
WM_CLOSE message is fired and its caught in the wndproc.
If you want to cancel the close operation after hiting close, you have to
use CancelEventArgs in Form_closing event.
The alternative way to code in File->Exit is to use
Application.ExitThread();
This wont hit wndproc. It will force the application to exit.
--
Shak
(Houston)
"John S" <jo********@cinfin.com> wrote in message
news:#h**************@TK2MSFTNGP10.phx.gbl...
I am trying to use this method to capture a user pressing the "X" in the
upper right-hand corner. I tried using the following code, but anytime I
exit the program it gets hit no matter what I press.
if(m.Msg == 0x0010) { //X button location
MessageBox.Show("Yeah i am close button here");
}
base.WndProc(ref m);
}