M
mac
Brand Newbie Alert!
I am working through the "Build a Program Now!" book by Microsoft Press.
The last chapter has a little app that should stay in the system tray when
the user clicks on the 'X' to close the form. It should only shutdown when
the user chooses an option from the context menu.
The book suggests writing code in the FormClosing event of the form "Main"
to modify the behavior of the 'X' menu on the form. I have reproduced the
code here:
private void Main_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
e.Cancel = true;
this.Hide(); // Book says to Hide() the form.
/*this.WindowState = FormWindowState.Minimized;
* I was inclined to set the WindowState instead. Is
* there a difference, and which approach is better?
*/
}
}
As I indicate in my comments, my first thought was to set the WindowState.
Which one makes more sense, and is there a difference?
Thanks,
Mac
P.S. Is it okay to send HTML in newsgroups, or is that bad form? I know it
makes the messages more readable, but are there a lot of front ends that can
only read plain text?
I am working through the "Build a Program Now!" book by Microsoft Press.
The last chapter has a little app that should stay in the system tray when
the user clicks on the 'X' to close the form. It should only shutdown when
the user chooses an option from the context menu.
The book suggests writing code in the FormClosing event of the form "Main"
to modify the behavior of the 'X' menu on the form. I have reproduced the
code here:
private void Main_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
e.Cancel = true;
this.Hide(); // Book says to Hide() the form.
/*this.WindowState = FormWindowState.Minimized;
* I was inclined to set the WindowState instead. Is
* there a difference, and which approach is better?
*/
}
}
As I indicate in my comments, my first thought was to set the WindowState.
Which one makes more sense, and is there a difference?
Thanks,
Mac
P.S. Is it okay to send HTML in newsgroups, or is that bad form? I know it
makes the messages more readable, but are there a lot of front ends that can
only read plain text?