By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,675 Members | 1,433 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,675 IT Pros & Developers. It's quick & easy.

Close to tray

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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" <bo********@hotmail.com> wrote in message
news:OL**************@tk2msftngp13.phx.gbl...
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

Nov 20 '05 #2

P: n/a
* "Shawn" <bo********@hotmail.com> scripsit:
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%3A*dotnet*+minimize+to+tray>

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #3

P: n/a
Works great!!
Thanks Tim

Shawn

"Tim Gallivan" <no**********************@edu.gov.on.ca> wrote in message
news:ur**************@tk2msftngp13.phx.gbl...
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" <bo********@hotmail.com> wrote in message
news:OL**************@tk2msftngp13.phx.gbl...
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


Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.