Hi VJ,
Thank you for your help

Where can I find the definitions of constants
like WM_SYSCOMMAND and SC_CLOSE, maybe there are other const that I
could use for future process, I find them useful.
Thanks,
Marty
VJ wrote:
Here is a sample to check if X button is clicked...
public const int SC_CLOSE = 61536;
public const int WM_SYSCOMMAND = 274;
public bool _closeClick = false;
protected override void WndProc(ref Message m)
{
if ( m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_CLOSE )
{
this._closeClick = true;
}
base.WndProc (ref m);
}
private Form1_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
if ( this._closeClick )
{
// X button clicked..
}
}
Sorry for the bad format.. my notepad is screwed up... and I had to
paste it directly from VS.NET code....
VJ
"Nicholas Paldino [.NET/C# MVP]" <
[email protected]>
wrote in message
Marty,
When you make a call to Close, why not set a flag in your form which
indicates that it is you who made the call. Then, in the on closing
event, you can check the flag. If it is set, you closed the form,
otherwise, the user did it, and you can perform whatever action you
need.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Hi,
How can I detect that a VS.NET2003 C# form is closed with the upper
right "X" button ?
This is because I want to add code to the myForm.OnClosing() event to
do a different process if a form is closed by the user (with the "X"
button) or if the form is closed with myForm.close().
Thank you!
Marty