I am attempting to intercept the close window but it seems to fail and close anyway for a form application. Essentially, this program should be waiting for input from a user on a signature pad and it pops up when someone starts signing but I need to prevent the program from being closed.
Here is what I tried that seems to have failed
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
//reset hardware
e.Cancel = true;
sigPlusNET1.LCDRefresh(0, 0, 0, 240, 64);
sigPlusNET1.LCDSetWindow(0, 0, 240, 64);
sigPlusNET1.SetSigWindow(1, 0, 0, 240, 64);
sigPlusNET1.KeyPadClearHotSpotList();
sigPlusNET1.SetLCDCaptureMode(1);
sigPlusNET1.SetTabletState(0);
this.Hide();
}
Any Ideas?
Edit: With this code, the app closes normally and does not hide.
Here is the section that works just fine:
// Ok Button
private void cmdClose_Click(object sender, EventArgs e)
{
//cmdSaveImage_Click(sender, e);
this.Visible = false;
sigPlusNET1.KeyPadClearHotSpotList();
sigPlusNET1.ClearTablet();
sigPlusNET1.KeyPadAddHotSpot(0, 1, 0, 0, 1000, 1000);
progTimer.Enabled = true;
}
Make sure that Form1_FormClosing
is specified in the form properties as the handler of the FormClosing
event.
Alternatively, you can override the actual method itself.
protected override void OnClosing(CancelEventArgs e)
{
e.Cancel = true;
base.OnClosing(e);
}