Anyway . .
Now its my turn to ask a question
I want to develop an app which will run in the system tray. How can I do
this?
Regards OHM
There is not much space in the system tray, so your app might get hurt. ;-))
Use the NotifyIcon component (System.Windows.Forms.NotifyIcon)
--
Armin
Basically: 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
Dim dialog as New OptionsDialog
dialog.ShowDialog()
dialog.Dispose()
End Sub
Private Sub menuExit_Click(...) Handles menuExit.Click
Application.Exit()
End Sub
End Sub
The problem is you cannot edit the menu from the Component Designer. You
can use cut & paste from a form to get the menu to the component...
Hope this helps
Jay
"One Handed Man [ OHM ]" <terry_burnsREMOVE%FOR%NO%SP...@BTOpenworld.com>
wrote in message news:e%23bszDUf...@TK2MSFTNGP12.phx.gbl...
*sigh*... I know you didn't just say that....
"Jay B. Harlow [MVP - Outlook]" <Jay_H...@email.msn.com> wrote in message
news:%23tsRCgU...@TK2MSFTNGP11.phx.gbl...
Public Sub New()
MyBase.New()
'This call is required by the Component Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
menuOptions.MenuItems.Clear()
menuOptions.MenuItems.Add("Exit", AddressOf HandleNIExit)
'Following two items need handlers written for them, but they goto the exit
handler for now
menuOptions.MenuItems.Add("Option1", AddressOf HandleNIExit)
menuOptions.MenuItems.Add("Option2", AddressOf HandleNIExit)
NotifyIcon1.ContextMenu = menuOptions
End Sub
AND
Sub HandleNIExit(ByVal sender As Object, ByVal e As System.EventArgs)
Application.Exit()
End Sub
"Jay B. Harlow [MVP - Outlook]" <Jay_H...@email.msn.com> wrote in message
news:%23tsRCgU...@TK2MSFTNGP11.phx.gbl...
"One Handed Man [ OHM ]" <terry_burnsREMOVE%FOR%NO%SP...@BTOpenworld.com>
wrote in message news:uNSJrcbf...@tk2msftngp13.phx.gbl...
Remember that the menu variables need to have WithEvents on them to support
the Handles clause on the Sub.
As you found out, there are at least 3 methods of doing things in .NET,
manually creating the menus is acceptable.
About the 3 seconds, I cannot find my sample. I want to say you need to
Dispose of the component to get the icon to disappear quicker.
If I find it later I will post the info.
Hope this helps
Jay
"One Handed Man [ OHM ]" <terry_burnsREMOVE%FOR%NO%SP...@BTOpenworld.com>
wrote in message news:eFgXndef...@TK2MSFTNGP09.phx.gbl...
In VS.NET this causes the icon to disappear 'immediately'.
FWI: you should use the NotifyIcon.MouseDown & NotifyIcon.MouseUp events if
you want to track which mouse button was pressed instead of the
NotifyIcon.Click event. I had 'trouble' with this when I first worked with
my sample. Took me 'for ever' to figure out what to do ;-)
Hope this helps
Jay
"One Handed Man [ OHM ]" <terry_burnsREMOVE%FOR%NO%SP...@BTOpenworld.com>
wrote in message news:eCht6eef...@TK2MSFTNGP12.phx.gbl...
1.) I need to call dispose before application exit
Right, as you suggest, the component object is removed immediatly when
disposed. What I would like to know is, if you do not do this first I guess
the application looks around for a while to see if it has any objects
associated with it before closing down ?
2.) In my variation of the code I simply added delegate handlers using the
constructor for the menuitem. I did not specifically add them withevents.
does this mean that this method does this implicitly, or have I dont
something wrong ?
Regards OHM
"Jay B. Harlow [MVP - Outlook]" <Jay_H...@email.msn.com> wrote in message
news:uGg0y9ef...@TK2MSFTNGP11.phx.gbl...
> 2.) In my variation of the code I simply added delegate handlers using the
The MenuItem constructor that accepts the delegate is calling AddHandler
inside. So yes the constructor is doing it implicitly. It is valid and is
easier when creating menus without the aid of the designer.
Hope this helps
Jay
"One Handed Man [ OHM ]" <terry_burnsREMOVE%FOR%NO%SP...@BTOpenworld.com>
wrote in message news:Oc$22zffD...@tk2msftngp13.phx.gbl...
Regards - OHM
"Jay B. Harlow [MVP - Outlook]" <Jay_H...@email.msn.com> wrote in message
news:eOLpo6ff...@TK2MSFTNGP09.phx.gbl...