Disabling Application.Exit?
Is there any way that I can modify my Windows.Form when I press the "Close-Box" (the "X")?
Background:
My app is running in the system tray, with WindowsState.Minimized and ShowInSystemTray == false.
When I select "Open app" from my ContextMenu, I change WindowsState from Minimized to Normal, which means that the app "pops-up" just the way I want it to do. So far, so good.
Now, I would like to make 2 things happen:
1) Disable the MaximizeBox (not remove it)
2) Change the behaviour when I click the close box, I want it to go back to its original form (running in the system tray)
If you have any good advice or pointers to where I might find information, I would be very grateful.
/ke D
[754 byte] By [
aake] at [2007-11-17 17:05:46]

# 1 Re: Disabling Application.Exit?
2) Change the behaviour when I click the close box, I want it to go back to its original form (running in the system tray)
On the form, set up an event handler for Closing event and follow the code snippet below.
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true; // Prevent form from closing
this.WindowState = FormWindowState.Minimized; // Minimize window
this.ShowInTaskbar = false; // remove from systray
}
I have no idea on the other one, however. If I come across anything, I'll let you know.