I overrode WndProc:
protected override void WndProc(ref Message m)
{
const int WM_SYSCOMMAND = 0x0112;
const int SC_CLOSE = 0xF060;
if (m.Msg == WM_SYSCOMMAND && (int) m.WParam ==
SC_CLOSE)
{
if (_BisSaving)
{
MessageBox.Show("Save in progress. Cannot close!", "ZIPMaster",
MessageBoxButtons.OK, MessageBoxIcon.Hand);
return;
}
}
base.WndProc(ref m);
}
"VMI" <vo******@yahoo.com> wrote in message
news:OO**************@TK2MSFTNGP09.phx.gbl...
How can I stop a form fro closing when the user tries to close it?
For example, in my code:
private void frm_audit_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
if (_BisSavingData)
{
// Code that will override the Closing method. I don't want the
form to close
}
else
{
// Continue closing the form
}
}