Skip to content

Commit 7788ee3

Browse files
committed
Update Program.cs
Fixed form closing with cancel
1 parent eae3912 commit 7788ee3

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

SRB2-Emblem-Displayer/Project1/Program.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,18 @@ static void MenuExit(object sender, EventArgs e)
315315
Environment.Exit(0);
316316
}
317317
}
318+
static void FormExit(object sender, FormClosingEventArgs e)
319+
{
320+
bool canceled = UnsavedChanges();
321+
if (canceled)
322+
{
323+
e.Cancel = true;
324+
}
325+
else
326+
{
327+
Environment.Exit(0);
328+
}
329+
}
318330
static void MenuIO_Options(object sender, EventArgs e)
319331
{
320332
previousFileName = fileName;
@@ -569,7 +581,7 @@ static void Main()
569581
MainForm.SizeGripStyle = SizeGripStyle.Hide;
570582
IOForm = MakeForm(new Size(295, 175), Color.FromArgb(240, 240, 240), "I/O Options");
571583
EditForm = MakeForm(new Size(245, 155), Color.FromArgb(240, 240, 240), "Edit Layout");
572-
MainForm.FormClosing += MenuExit;
584+
MainForm.FormClosing += FormExit;
573585
MainForm.ResizeEnd += ResizeEnd;
574586

575587
emblemLabel = new Label();

0 commit comments

Comments
 (0)