A
Andreas Selle
Hi,
right now I am facing the following Problem and cannot find a solution for
it:
In my Dialog (Form shown with ShowDialog) I have some field validation code
inside the overridden OnClosing method. Whenever the user tries to close the
Form (usually by tapping OK) with some invalid input I show a nice message
and prevent that the Form is closed. Works great.
There is one caveat however: Apart from tapping OK, the Form may also be
closed by terminating the application through a task manager that sends
WM_CLOSE to the actual Form Window. As expected, in this case OnClosing will
be called, too. However, in this case I would prefer to not validate the
input, but rather ignore any false inputs such that the application can be
shut down silently and gracefully. This raises the problem how to tell
whether the Form was closed by tapping OK or whether it was closed through
some other means.
My first idea was to check the DialogResult property, but this always
contains DialogResult.None when OnClosing is invoked.
Does anybody have an idea how to solve this problem?
Thanks
Andreas
right now I am facing the following Problem and cannot find a solution for
it:
In my Dialog (Form shown with ShowDialog) I have some field validation code
inside the overridden OnClosing method. Whenever the user tries to close the
Form (usually by tapping OK) with some invalid input I show a nice message
and prevent that the Form is closed. Works great.
There is one caveat however: Apart from tapping OK, the Form may also be
closed by terminating the application through a task manager that sends
WM_CLOSE to the actual Form Window. As expected, in this case OnClosing will
be called, too. However, in this case I would prefer to not validate the
input, but rather ignore any false inputs such that the application can be
shut down silently and gracefully. This raises the problem how to tell
whether the Form was closed by tapping OK or whether it was closed through
some other means.
My first idea was to check the DialogResult property, but this always
contains DialogResult.None when OnClosing is invoked.
Does anybody have an idea how to solve this problem?
Thanks
Andreas