PsychoCoder
Programmer
Hello all,
This is driving me crazy (not that its too long of a trip). I have created a custom NotifyIcon class file, as far as displaying the icon in the system tray and sending the balloon messages it works great. I actually have 2 class files in one, one is a listener the other is the actual NotifyIcon file.
In the Listener class I have added events:
In the actual NotifyIcon file I have a ContextMenu Property:
And the Event Handlers:
But in the application I cannot get the ContextMenuStrip to show when a right-click is execute. Any help would be greatly appreciated.
Senior Qik III, ASP.Net, VB.Net ,SQL Programmer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is driving me crazy (not that its too long of a trip). I have created a custom NotifyIcon class file, as far as displaying the icon in the system tray and sending the balloon messages it works great. I actually have 2 class files in one, one is a listener the other is the actual NotifyIcon file.
In the Listener class I have added events:
Code:
Public Shadows Event Click(ByVal sender As Object, ByVal e As System.EventArgs)
Public Shadows Event DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs)
Public Shadows Event MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Public Shadows Event MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Public Shadows Event MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Public Event Reload()
Public Event BalloonShow(ByVal sender As Object)
Public Event BalloonHide(ByVal sender As Object)
Public Event BalloonTimeout(ByVal sender As Object)
Public Event BalloonClick(ByVal sender As Object)
Private WM_TASKBARCREATED As Int32 = RegisterWindowMessage("TaskbarCreated")
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Select Case m.Msg
Case WM_USER_TRAY
Select Case m.LParam.ToInt32
Case WM_LBUTTONDBLCLK, WM_RBUTTONDBLCLK, WM_MBUTTONDBLCLK
RaiseEvent DoubleClick(Me, New MouseEventArgs(MouseButtons, 0, MousePosition.X, MousePosition.Y, 0))
Case WM_LBUTTONDOWN, WM_RBUTTONDOWN, WM_MBUTTONDOWN
RaiseEvent MouseDown(Me, New MouseEventArgs(MouseButtons, 0, MousePosition.X, MousePosition.Y, 0))
Case WM_MOUSEMOVE
RaiseEvent MouseMove(Me, New MouseEventArgs(MouseButtons, 0, MousePosition.X, MousePosition.Y, 0))
Case WM_LBUTTONUP
RaiseEvent MouseUp(Me, New MouseEventArgs(Windows.Forms.MouseButtons.Left, 0, MousePosition.X, MousePosition.Y, 0))
RaiseEvent Click(Me, New MouseEventArgs(Windows.Forms.MouseButtons.Left, 0, MousePosition.X, MousePosition.Y, 0))
Case WM_RBUTTONUP
RaiseEvent MouseUp(Me, New MouseEventArgs(Windows.Forms.MouseButtons.Right, 0, MousePosition.X, MousePosition.Y, 0))
RaiseEvent Click(Me, New MouseEventArgs(Windows.Forms.MouseButtons.Right, 0, MousePosition.X, MousePosition.Y, 0))
Case WM_MBUTTONUP
RaiseEvent MouseUp(Me, New MouseEventArgs(Windows.Forms.MouseButtons.Middle, 0, MousePosition.X, MousePosition.Y, 0))
RaiseEvent Click(Me, New MouseEventArgs(Windows.Forms.MouseButtons.Middle, 0, MousePosition.X, MousePosition.Y, 0))
Case NIN_BALLOONSHOW
RaiseEvent BalloonShow(Me)
Case NIN_BALLOONHIDE
RaiseEvent BalloonHide(Me)
Case NIN_BALLOONTIMEOUT
RaiseEvent BalloonTimeout(Me)
Case NIN_BALLOONUSERCLICK
RaiseEvent BalloonClick(Me)
Case Else
Debug.WriteLine(m.LParam.ToInt32)
End Select
Case WM_TASKBARCREATED
RaiseEvent Reload()
Case Else
End Select
MyBase.WndProc(m)
End Sub
In the actual NotifyIcon file I have a ContextMenu Property:
Code:
Public Property ContextMenu() As System.Windows.Forms.ContextMenuStrip
Get
Return m_ContextMenu
End Get
Set(ByVal Value As System.Windows.Forms.ContextMenuStrip)
m_ContextMenu = Value
End Set
End Property
And the Event Handlers:
Code:
Public Event Click(ByVal sender As Object, ByVal e As System.EventArgs)
Public Event DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs)
Public Event RightClick(ByVal sender As Object, ByVal e As System.EventArgs)
Public Event MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Public Event MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Public Event MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Public Event BalloonShow(ByVal sender As Object)
Public Event BalloonHide(ByVal sender As Object)
Public Event BalloonTimeout(ByVal sender As Object)
Public Event BalloonClick(ByVal sender As Object)
Private Shadows Sub Messages_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Messages.Click
RaiseEvent Click(Me, e)
End Sub
Private Shadows Sub Messages_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Messages.DoubleClick
RaiseEvent DoubleClick(Me, e)
End Sub
Private Shadows Sub Messages_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Messages.MouseDown
RaiseEvent MouseDown(Me, e)
End Sub
Private Shadows Sub Messages_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Messages.MouseMove
RaiseEvent MouseMove(Me, e)
End Sub
Private Shadows Sub Messages_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Messages.MouseUp
RaiseEvent MouseUp(Me, e)
If e.Button = MouseButtons.Right Then
Messages.Activate()
Dim Position As Point = New Point(Cursor.Position.X - Messages.PointToScreen(New Point(0, 0)).X, Cursor.Position.Y - Messages.PointToScreen(New Point(0, 0)).Y)
If Not m_ContextMenu Is Nothing Then m_ContextMenu.Show(Messages, Position)
'MsgBox("Set right-click!", MsgBoxStyle.OkOnly)
End If
End Sub
But in the application I cannot get the ContextMenuStrip to show when a right-click is execute. Any help would be greatly appreciated.
Senior Qik III, ASP.Net, VB.Net ,SQL Programmer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"In the new millennium there will be two kinds of business; those on the net and those out of business"
~ Bill Gates ~