Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As NIM_CONSTANTS, pnid As NOTIFYICONDATA) As Boolean
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Private Declare Function TrackPopupMenu Lib "user32" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal X As Long, ByVal Y As Long, ByVal nReserved As Long, ByVal hWnd As Long, ByVal lprc As Long) As Long
Dim IconData As NOTIFYICONDATA
Dim m_ToolTipText As String
Dim m_Visible As Boolean
Dim m_Show As Boolean
Dim m_SysMenu As Boolean
Event MouseMove()
Event MouseDown(Button As Integer)
Event MouseUp(Button As Integer)
Event DblClick(Button As Integer)
Event Click(Button As Integer)
Event SingleClick(Button As Integer)
Public Property Get ToolTipText() As String
Attribute ToolTipText.VB_Description = "Gibt den Text zurⁿck, der angezeigt wird, wenn die Maus ⁿber dem Steuerelement verweilt, oder legt den Text fest."
ToolTipText = IconData.szTip
End Property
Public Property Let ToolTipText(ByVal New_ToolTipText As String)
m_ToolTipText = New_ToolTipText
IconData.szTip = m_ToolTipText & Chr(0)
PropertyChanged "ToolTipText"
If m_Show Then Shell_NotifyIcon NIM_MODIFY, IconData
End Property
Public Property Get Icon() As StdPicture
Set Icon = Picture
End Property
Public Property Set Icon(ByVal New_Icon As StdPicture)
Set Picture = New_Icon
PropertyChanged "Icon"
IconData.hIcon = New_Icon.Handle
If m_Show Then Shell_NotifyIcon NIM_MODIFY, IconData
End Property
Public Property Get Visible() As Boolean
Visible = m_Visible
End Property
Public Property Let Visible(ByVal New_Visible As Boolean)
m_Visible = New_Visible
PropertyChanged "Visible"
Show m_Visible
End Property
Public Property Get SysMenu() As Boolean
SysMenu = m_SysMenu
End Property
Public Property Let SysMenu(ByVal New_SysMenu As Boolean)
m_SysMenu = New_SysMenu
PropertyChanged "SysMenu"
End Property
Private Sub tmrMenu_Timer()
tmrMenu.Enabled = False
RaiseEvent SingleClick(1)
End Sub
Private Sub UserControl_Initialize()
IconData.cbSize = Len(IconData)
IconData.hWnd = hWnd
IconData.uId = vbNull
IconData.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
IconData.uCallBackMessage = WM_MOUSEMOVE
End Sub
Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Select Case X
Case WM_MOUSEMOVE: RaiseEvent MouseMove
Case WM_LBUTTONDBLCLK: RaiseEvent DblClick(1)
Case WM_LBUTTONDOWN: RaiseEvent MouseDown(1)
Case WM_LBUTTONUP
RaiseEvent MouseUp(1)
RaiseEvent Click(1)
tmrMenu.Enabled = Not tmrMenu.Enabled
Case WM_RBUTTONDBLCLK: RaiseEvent DblClick(2)
Case WM_RBUTTONDOWN: RaiseEvent MouseDown(2)
Case WM_RBUTTONUP
If m_SysMenu Then
ShowSysMenu
Else
RaiseEvent MouseUp(2): RaiseEvent Click(2)
End If
End Select
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)