S
Stephan Steiner
Hi
I need a special variant of catching the OnClosing event. Basically I want
OnClosing to not close the form if the X button has been pressed, but to
minimize it. So far, no problem. The problem is that I don't know a way to
figure out if the event is thrown because the user pressed the X button in
the upper right, or because he pressed Alt-F4, or because the application is
supposed to shut down because the user logs out. In the latter two cases,
I'm effectively preventing proper operation with my code now.
So, I need:
X button: minimize and hide form
Alt-F4 / User logoff /restarting PC: close application
I've already tried registering an eventhandler for the Closing event and
have a look at the sender, but sender is always my form so that didn't do me
any good. And the CancelEventArgs don't contain any information that would
be of use here, either.
Does anybody have an idea of how I can achieve this?
Regards
Stephan
I need a special variant of catching the OnClosing event. Basically I want
OnClosing to not close the form if the X button has been pressed, but to
minimize it. So far, no problem. The problem is that I don't know a way to
figure out if the event is thrown because the user pressed the X button in
the upper right, or because he pressed Alt-F4, or because the application is
supposed to shut down because the user logs out. In the latter two cases,
I'm effectively preventing proper operation with my code now.
So, I need:
X button: minimize and hide form
Alt-F4 / User logoff /restarting PC: close application
I've already tried registering an eventhandler for the Closing event and
have a look at the sender, but sender is always my form so that didn't do me
any good. And the CancelEventArgs don't contain any information that would
be of use here, either.
Does anybody have an idea of how I can achieve this?
Regards
Stephan