Board index » Visual Studio » Stopping windows from shutting down
|
Nol
|
|
Nol
|
Stopping windows from shutting down
Visual Studio280
I need to stop windows from shutting down, but only if <condition>is true. This is probably an easy thing to do, I looked in help for 30 minutes but couldn't find it. Thanks in Advance - |
| Jeff
Registered User |
Wed Jun 01 13:06:53 CDT 2005
Re:Stopping windows from shutting down"Richard M. Geis" <rmgeis@burnoutboss.com>wrote in message QuoteI need to stop windows from shutting down, but only if <condition>is true. and the Cancel parameters. - |
| Bob
Registered User |
Wed Jun 01 13:47:24 CDT 2005
Re:Stopping windows from shutting down
"Jeff Johnson [MVP: VB]" <i.get@enough.spam>wrote in message
Quote"Richard M. Geis" <rmgeis@burnoutboss.com>wrote in message to stop it (and AFAIK you can't detect that except maybe by responding to the Form_Unload event) -- Reply to the group so all can participate VB.Net: "Fool me once..." - |
| Gerald
Registered User |
Wed Jun 01 14:53:13 CDT 2005
Re:Stopping windows from shutting down"Richard M. Geis" <rmgeis@burnoutboss.com>wrote in message QuoteI need to stop windows from shutting down, but only if <condition>is or stopping "Windows" OS from shutting down? Gerald - |
| Richard
Registered User |
Wed Jun 01 19:17:03 CDT 2005
Re:Stopping windows from shutting down
What I would like is a message box to come up like one does if you try
to shut down windows without saving text in notepad. Of course, one of the options would stop windows from shuting down (or cancel shut down). I have the following code in the form (unload) event but it has no effect on windows shuying down: Private Sub Form_Unload(Cancel As Integer) j = 0 For i = 0 To furninst - 1 If furnon(i) = True Or furnwait(i)>0 Then j = j + 1 If furndone(i) = True Then j = j - 1 Next i If j>0 Then If MsgBox("Furnace is currently running, close anyway?", vbYesNo, "Warning") = vbNo Then Cancel = 1 End If End If End Sub Thanks Gerald Hernandez wrote: Quote"Richard M. Geis" <rmgeis@burnoutboss.com>wrote in message |
| Bob
Registered User |
Wed Jun 01 19:46:42 CDT 2005
Re:Stopping windows from shutting down
"Richard M. Geis" <rmgeis@burnoutboss.com>wrote in message
QuoteWhat I would like is a message box to come up like one does if you try Form_QueryUnload and try it. -- Reply to the group so all can participate VB.Net: "Fool me once..." - |
| MikeD
Registered User |
Wed Jun 01 19:53:28 CDT 2005
Re:Stopping windows from shutting down"Richard M. Geis" <rmgeis@burnoutboss.com>wrote in message QuoteWhat I would like is a message box to come up like one does if you try to You need to move that code to the QueryUnload event and check the UnloadMode argument to see if Windows is shutting down. Personally, I would advise against any such prompt unless it would be detrimental to have Windows close at that particular time. Normally, you shouldn't interfere with Windows shutting down. If a shutdown would be detrimental, you should just do whatever you need to properly clean up and then let Windows continue to shut down. I can think of no good reason a program should interrupt a shut down except to prompt to save data which has not been saved. Even security programs like virus checkers and firewalls don't normally interrupt a shutdown of Windows. -- Mike Microsoft MVP Visual Basic - |
| Richard
Registered User |
Wed Jun 01 20:37:28 CDT 2005
Re:Stopping windows from shutting down
Thanks for the replies. That did stop windows from shutting down. I
needed to do this because this application runs a furnace through a com port. I once accidentally shut down windows in the middle of running a furnace and it took two hours to get back to where I was. Another interesting note: this dosen't work when running inside of VB, it has to be compiled and run from the .exe Thnaks again, and sorry you had to tell me twice. MikeD wrote: Quote"Richard M. Geis" <rmgeis@burnoutboss.com>wrote in message |
