J
John Savidge
I have the following code in a class in my simple forms application, its in
the early stages. I am a VB.net newbie and have a question I am hoping
someone could help me on.
Assuming I know how to distinguish between left and right mouse clicks, how
do I access the click events of the contect menu I have added to my
notification icon? At the moment simply clicking the notification icon will
show / hide the form or start a new instance of the form if the user exits
the form.
Class1 is my startup object.
TIA
John
My code is below...
Public Class Class1
Private WithEvents nI As Windows.Forms.NotifyIcon
Private WithEvents cM As Windows.Forms.ContextMenu
Private m_frm As New frmsysmanager
Shared Sub Main()
Dim objClass1 As New Class1
Windows.Forms.Application.Run()
End Sub
Sub New()
MyBase.New()
Dim resources As Resources.ResourceManager = New
Resources.ResourceManager(GetType(Class1))
nI = New Windows.Forms.NotifyIcon
cM = New Windows.Forms.ContextMenu
nI.Icon = CType(resources.GetObject("NotifyIcon1.Icon"),
System.Drawing.Icon)
nI.Visible = True
cM.MenuItems.Add("Open Window")
cM.MenuItems.Add("Minimise to Tray")
nI.ContextMenu = cM
End Sub
Private Sub nI_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles nI.Click
If m_frm Is Nothing OrElse m_frm.IsDisposed Then
m_frm = New frmSysManager
Else
With m_frm
If .Visible = True Then
..Hide()
Else
..Show()
..Focus()
End If
End With
End If
End Sub
End Class
the early stages. I am a VB.net newbie and have a question I am hoping
someone could help me on.
Assuming I know how to distinguish between left and right mouse clicks, how
do I access the click events of the contect menu I have added to my
notification icon? At the moment simply clicking the notification icon will
show / hide the form or start a new instance of the form if the user exits
the form.
Class1 is my startup object.
TIA
John
My code is below...
Public Class Class1
Private WithEvents nI As Windows.Forms.NotifyIcon
Private WithEvents cM As Windows.Forms.ContextMenu
Private m_frm As New frmsysmanager
Shared Sub Main()
Dim objClass1 As New Class1
Windows.Forms.Application.Run()
End Sub
Sub New()
MyBase.New()
Dim resources As Resources.ResourceManager = New
Resources.ResourceManager(GetType(Class1))
nI = New Windows.Forms.NotifyIcon
cM = New Windows.Forms.ContextMenu
nI.Icon = CType(resources.GetObject("NotifyIcon1.Icon"),
System.Drawing.Icon)
nI.Visible = True
cM.MenuItems.Add("Open Window")
cM.MenuItems.Add("Minimise to Tray")
nI.ContextMenu = cM
End Sub
Private Sub nI_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles nI.Click
If m_frm Is Nothing OrElse m_frm.IsDisposed Then
m_frm = New frmSysManager
Else
With m_frm
If .Visible = True Then
..Hide()
Else
..Show()
..Focus()
End If
End With
End If
End Sub
End Class