Private Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const NIF_MESSAGE = &H1
Private Const NIF_ICON = &H2
Private Const NIF_TIP = &H4
Private Const NIM_ADD = &H0
Private Const NIM_MODIFY = &H1
Private Const NIM_DELETE = &H2
Private Const WM_RBUTTONDOWN = &H204
Private Const WM_NULL = &H0
Private Type NOTIFYICONDATA
cbSize As Long
hWnd As Long
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As Long
szTip As String * 64
End Type
Private NID As NOTIFYICONDATA
Private m_hWnd As Long
Private m_Icon As Long
Private m_ToolTipText As String
Public Enum TrayIcon_Mouse
TRAYICON_MOUSE_NONE = 0
TRAYICON_MOUSE_LEFTDOWN = 1
TRAYICON_MOUSE_LEFTUP = 2
TRAYICON_MOUSE_LEFTDBLCLICK = 3
TRAYICON_MOUSE_RIGHTDOWN = 4
TRAYICON_MOUSE_RIGHTUP = 5
TRAYICON_MOUSE_RIGHTDBLCLICK = 6
End Enum
Public Sub Add(hWnd As Long, Icon As Long, Tip As String)
Dim ret As Long
NID.uID = hWnd
NID.hWnd = hWnd
NID.hIcon = Icon
NID.szTip = Left(Tip, 63) & Chr(0)
NID.uFlags = NIF_TIP + NIF_MESSAGE + NIF_ICON
NID.uCallbackMessage = WM_RBUTTONDOWN
NID.cbSize = Len(NID)
ret = Shell_NotifyIcon(NIM_ADD, NID)
End Sub
Public Sub Delite(hWnd As Long)
Dim ret As Long
NID.uID = hWnd
NID.hWnd = hWnd
NID.cbSize = Len(NID)
ret = Shell_NotifyIcon(NIM_DELETE, NID)
End Sub
Function TestTray(X As Single, Y As Single)
Dim MouseButton As Integer
If frmSet.Visible = True Or Not Y = 0 Then Exit Function
MouseButton = (X And &HFF) / Screen.TwipsPerPixelX
DoEvents
If MouseButton = 4 Then
DoEvents
//ТО ЧТО НАДО ПРИ ЩЕЛЧКЕ ПРАВОЙ КНОПКОЙ
DoEvents
End If
End Function
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
TestTray X, Y
End Sub
Сейчас этот форум просматривают: AhrefsBot и гости: 64