P
Phuff
I have an application that should run in the system tray while open.
It is supposed to be open at all times and I need it to dissapear when
the "X" button is pushed on the form...but without closing the app.
I've tried overriding the closing event
but when you try to shutdown windows or reboot it will cancel the event
and windows can't shutdown without closing my app first.
So I tried to override the WndProc() method and catch the message for a
system shutdown.
<code>
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand,
Name:="FullTrust")> _
Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
' Listen for operating system messages
Select Case (m.Msg)
Case WM_QUERYENDSESSION
Application.Exit()
End Select
' Handle the message
MyBase.WndProc(m)
End Sub
</code>
This will close my app while windows is Shutting down/rebooting but it
will still cancel the shut down process. I've been looking everywhere
and can't seem to find how to do this. I tried using WndProc to catch
the message sent by the "X" button and did so successfully, but it
would still close the app.
Any help would be greatly appreciated!!
Paul Huff
It is supposed to be open at all times and I need it to dissapear when
the "X" button is pushed on the form...but without closing the app.
I've tried overriding the closing event
Private Sub frmMain_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
'Don't close this form
e.Cancel = True
Me.Hide()
End Sub
but when you try to shutdown windows or reboot it will cancel the event
and windows can't shutdown without closing my app first.
So I tried to override the WndProc() method and catch the message for a
system shutdown.
<code>
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand,
Name:="FullTrust")> _
Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
' Listen for operating system messages
Select Case (m.Msg)
Case WM_QUERYENDSESSION
Application.Exit()
End Select
' Handle the message
MyBase.WndProc(m)
End Sub
</code>
This will close my app while windows is Shutting down/rebooting but it
will still cancel the shut down process. I've been looking everywhere
and can't seem to find how to do this. I tried using WndProc to catch
the message sent by the "X" button and did so successfully, but it
would still close the app.
Any help would be greatly appreciated!!
Paul Huff