Close to tray

  • Thread starter Thread starter Shawn
  • Start date Start date
S

Shawn

Hi. I've created an application that can run in the system tray. The way it
works now I have to click a button to "send" the application to the system
tray, but I want the application to run in the tray whenever the user clicks
either the minimize or close button on the form.. How can I do that? I
have to be able to tell the application not to exit whenever the forms exit
button is clicked..

Any help is greatly appreciated!
Shawn
 
Try this:

Protected Overrides Sub WndProc(ByRef m As Message)
Const WM_SYSCOMMAND As Integer = &H112
Const SC_CLOSE As Integer = &HF060

If m.Msg = WM_SYSCOMMAND And m.WParam.ToInt32 = SC_CLOSE Then
' User clicked close button
Me.Hide()
Return
End If

MyBase.WndProc(m)

End Sub 'WndProc
 
* "Shawn said:
Hi. I've created an application that can run in the system tray. The way it
works now I have to click a button to "send" the application to the system
tray, but I want the application to run in the tray whenever the user clicks
either the minimize or close button on the form.. How can I do that? I
have to be able to tell the application not to exit whenever the forms exit
button is clicked..

<http://groups.google.de/groups?ie=UTF-8&q=group:*dotnet*+minimize+to+tray>
 
Works great!!
Thanks Tim

Shawn



Try this:

Protected Overrides Sub WndProc(ByRef m As Message)
Const WM_SYSCOMMAND As Integer = &H112
Const SC_CLOSE As Integer = &HF060

If m.Msg = WM_SYSCOMMAND And m.WParam.ToInt32 = SC_CLOSE Then
' User clicked close button
Me.Hide()
Return
End If

MyBase.WndProc(m)

End Sub 'WndProc
 
Back
Top