Re: Windows won't shut down
From: Nicholas Paldino [.NET/C# MVP] (mvp_at_spam.guard.caspershouse.com)
Date: 10/07/04
- Next message: Stephan Schlicker: "Re: Serilization problems"
- Previous message: Richard Blewett [DevelopMentor]: "Re: Interesting Delay After Thread.Abort()"
- In reply to: Claire: "Windows won't shut down"
- Next in thread: david.kao_at_opco.com: "Re: Windows won't shut down"
- Reply: david.kao_at_opco.com: "Re: Windows won't shut down"
- Reply: Claire: "Re: Windows won't shut down"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 7 Oct 2004 09:16:38 -0400
Claire,
I don't think that is the case. When windows is shutting down, if your
app cancels the request to shut down, then it will halt the shutdown.
I think that you should override the WndProc method of your form, and
then handle the WM_QUERYENDSESSION and WM_ENDSESSION messages yourself,
indicating that it is ok to shut down when you get them. I think that the
cancel request from your Closing event handler is being channeled back in
response to these messages.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
"Claire" <asdfkjasl@ntlworld.com> wrote in message
news:%23VpjArGrEHA.3748@TK2MSFTNGP09.phx.gbl...
> Running XP pro, SP2. Visual studio .NET 2003. App written in C#
>
> I have written an application that hides itself when run and shows a
> notification icon in the system tray.
> If the main form is visible/restored to the desktop, and I tell windows to
> restart, windows shuts down fine.
> If the main form is minimized to the tray and I tell windows to restart,
> other desktop apps close down fine but my program's icon remains sat in
> the
> system tray, windows doesn't close down and there's no error messages.
> In normal use, I only allow the app to close down from a right button
> mouse
> activated menu when the app sits in the task bar.
>
> The code for the Closing event is as follows. The menu "close application"
> click changes the DialogResult from None to Cancel.
> I tested and found that the Closing event is being called in both cases
> and
> ,afaik, the result should be ignored anyway as Windows OS is being closed
> down.
> private void frmOptions_Closing(object sender,
> System.ComponentModel.CancelEventArgs e)
>
> {
>
> if (DialogResult == DialogResult.None)
>
> {
>
> e.Cancel = true;
>
> WindowState = FormWindowState.Minimized;
>
> }
>
>
> }
>
- Next message: Stephan Schlicker: "Re: Serilization problems"
- Previous message: Richard Blewett [DevelopMentor]: "Re: Interesting Delay After Thread.Abort()"
- In reply to: Claire: "Windows won't shut down"
- Next in thread: david.kao_at_opco.com: "Re: Windows won't shut down"
- Reply: david.kao_at_opco.com: "Re: Windows won't shut down"
- Reply: Claire: "Re: Windows won't shut down"
- Messages sorted by: [ date ] [ thread ]