On Thu, 09 Oct 2008 12:32:34 -0700, Looch <lu**********@yahoo.comwrote:
All,
I have a form that has a text box and button - when the button is
pressed the form will close if the correct text is in the text box -
works fine.
However, if the text box is blank I can't reboot a Windows PC which I
want to allow (if I enter the correct text it will reboot). Is there
anything I can check in the form's OnClosing method to see if Windows
is trying to close the form as opposed to a user closing the form?
A concise-but-complete code sample that demonstrates the issue might be
helpful. Even with validation, a logout/reboot would normally still
shutdown the application. So you must have some other code that is
somehow blocking that from happening. But without seeing the code, it's
difficult to know what it's doing.
As a general rule, you can use the Application.SessionEnding event to
watch for, and even respond to, scenarios where the user is trying to
logout or the system is trying to reboot. But normally you wouldn't need
to handle that just to deal with a control validation issue; the
validation is skipped altogether during a shutdown. So something else
must be going on. Maybe handling SessionEnding will help you fix it, but
it's not possible to say without more details.
Pete