Well you know how in notepad or paint or whatever program you go to close it and it asks if you want to save first right?
Well if you click yes, it saves, no it just closes, and cancel which cancels the close. How would I do this?
I'm guessing you'd use C's signal(<SIGNAL>, <HANDLER>) function, but I could be wrong.
EDIT:
Looks like I was: Linky (http://www.geekpedia.com/KB9_How-do-I-stop-the-form-from-closing-or-How-do-I-prompt-the-user-to-confirm-the-closing-of-the-application-when-he-presses-the-X-button.html)
this is the code I used to stop the RMX-OS GUI from closing and untill it kew if you wanted to run in the task bar
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.rmxos_closing);
private void rmxos_closing(object sender, FormClosingEventArgs e)
{
if (runingintaskbar == false)
{
DialogResult result = MessageBox.Show("Do you want to keep running in the task bar?", "Closing", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
e.Cancel = true;
minimize_to_tray();
}
else
{
if (cfg_saved == false)
{
DialogResult result2 = MessageBox.Show("The configuration data has not been saved \r\n would you like to save now?", "CFG Not Saved!", MessageBoxButtons.YesNo);
if (result2 == DialogResult.Yes)
{
save_data();
}
}
if (serverRunState == true)
{
RmxosProcess.Kill();
}
}
}
else
{
if (cfg_saved == false)
{
DialogResult result2 = MessageBox.Show("The configuration data has not been saved \r\n would you like to save now?", "CFG Not Saved!", MessageBoxButtons.YesNo);
if (result2 == DialogResult.Yes)
{
save_data();
}
}
if (serverRunState == true)
{
RmxosProcess.Kill();
}
}
}
"this" being the Form insistence
There's an event called FormClosing. Just define a method that is called at that moment and abort it. I can't remember how exactly I did it, but if you still have the Blizz-ABS Config source, I did it in there to make the saving before closing dialog possible.
Ryex beat me to it. >8U
@LF: That's for C in Unix. He's using C# in Windows. -_-
Quote from: Blizzard on October 30, 2009, 06:33:09 pm
There's an event called FormClosing. Just define a method that is called at that moment and abort it. I can't remember how exactly I did it, but if you still have the Blizz-ABS Config source, I did it in there to make the saving before closing dialog possible.
Ryex beat me to it. >8U
@LF: That's for C in Unix. He's using C# in Windows. -_-
Holy crap, Windows doesn't support signal()?
Holy crap, C# doesn't support C functions?
Windows doesn't have signals. Interrupts are handled in a different way.
Thanks guys! Got it working *lv's up ryex*