I have an application that sits in the task tray and when the user issues a shutdown request I intercept using the following code:
I am not going to include all the DLLImport code to shorten post a little.
Then in my _FormClosing event I have the following code:Code:protected override void WndProc(ref System.Windows.Forms.Message m) { if ((m.Msg == 0x11) || (m.Msg == 0x0016) || (m.Msg == 0xA123)) // WM_QUERYENDSESSION Or WM_ENDSESSION Or RF_UNLOADMSG { // Check for Windows shutdown event _WindowsShutdownRequested = true; Application.Exit(); } else base.WndProc(ref m); }
This all seems to work fine, but even though my app closes and is removed from the task tray, Windows doesn't continue to shutdown. I have to click sutdown again.Code:private void FormSettings_FormClosing(object sender, FormClosingEventArgs e) { // Check for Windows shutdown event if (!_WindowsShutdownRequested) { // Code to minimize to tray goes here... } }
Do theses messages only listen for the shutdown event and abort it or am I doing something wrong in my code?
Thanks in advance,
CT




Reply With Quote