|
|
Joined: Dec 1999
Posts: 30,867
Master Elite Member
|
Rather than using a Form as the startup object, use a Component instead. Create a new Component class (use Project - Add Component). Add a NotifyIcon to the component designer. Also add a ContextMenu object for the NotifyIcon. When you click the menu, create and show the form. Remember to put an Exit option on the menu. Make the Component the startup object, adding a Shared Sub Main to the component. Public Class Component1
Inherits System.ComponentModel.Component
' Component designer generated code omitted.
Public Shared Sub Main
Dim app as New Component1
Application.Run()
End Sub
Private Sub menuOptions_Click(...) Handles menuOptions.Click
' this would be your settings dialog.
Dim dialog as New OptionsDialog
dialog.ShowDialog()
dialog.Dispose()
End Sub
Private Sub menuExit_Click(...) Handles menuExit.Click
Me.Dispose()
Application.Exit()
End Sub
End Class The problem is you cannot edit the menu from the Component Designer. What I do is use cut & paste from a Form Designer onto the Component Designer to get the menu to the component... The call to Me.Dispose enables the icon to be removed from the system tray right away rather then waiting. Source: http://bytes.com/forum/thread371148.html
|
|
|
|
|