Работа с треем


'+-------------------------------------+

'|        Работа с Tray'ем             |

'|       универсальный модуль          |

'| Большой сенкс добрым ФИДОшникам за  |

'|    предоставление этого модуля      |

'+-------------------------------------+





'всякие константы

Public Const NIF_MESSAGE = &H1

Public Const NIF_ICON = &H2

Public Const NIF_TIP = &H4

Public Const NIM_ADD = &H0

Public Const NIM_MODIFY = &H1

Public Const NIM_DELETE = &H2

Public Const WM_RBUTTONDOWN = &H204



'структурка

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



Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias _

 "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) _

 As Long





'Добавление иконки в Tray

Public Sub AddTrayIcon(IDhWnd As Long, Icon As Long, Text As String)

    NID.szTip = Left$(Text, 63) & Chr$(0)

    NID.uFlags = NIF_TIP + NIF_MESSAGE + NIF_ICON

    NID.uID = IDhWnd

    NID.cbSize = Len(NID)

    NID.hWnd = IDhWnd

    NID.uCallbackMessage = WM_RBUTTONDOWN

    NID.hIcon = Icon

    Res& = Shell_NotifyIcon(NIM_ADD, NID)

End Sub



'Удаление иконки из Tray

Public Sub DeleteTrayIcon()

    NID.cbSize = Len(NID)

    Res& = Shell_NotifyIcon(NIM_DELETE, NID)

End Sub



'Изменение иконки и ToolTip в Tray

Public Sub ItemModify(Icon As Long, Text As String)

    NID.uFlags = NIF_TIP + NIF_ICON

    NID.cbSize = Len(NID)

    NID.szTip = Left$(Text, 63) & Chr$(0)

    NID.hIcon = Icon

    Res& = Shell_NotifyIcon(NIM_MODIFY, NID)

End Sub



к оглавлению
Используются технологии uCoz