ใ่ส่ไว้ที่ Form นะครับ …
Dim nid As NOTIFYICONDATA Sub minimize_to_tray() Me.Hide nid.cbSize = Len(nid) nid.hwnd = Me.hwnd nid.uId = vbNull nid.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE nid.uCallBackMessage = WM_MOUSEMOVE nid.hIcon = Me.Icon nid.szTip = "blablabla text u want to show when mouse over tray iicon" & vbNullChar Shell_NotifyIcon NIM_ADD, nid End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) Dim msg As Long Dim sFilter As String msg = x / Screen.TwipsPerPixelX Select Case msg Case WM_LBUTTONDOWN Me.Show Shell_NotifyIcon NIM_DELETE, nid Case WM_LBUTTONUP Case WM_LBUTTONDBLCLK Case WM_RBUTTONDOWN Case WM_RBUTTONUP Me.Show Shell_NotifyIcon NIM_DELETE, nid Case WM_RBUTTONDBLCLK End Select End Sub Private Sub Form_Unload(Cancel As Integer) Shell_NotifyIcon NIM_DELETE, nid End Sub Private Sub form_resize() If (Me.WindowState = vbMinimized) Then minimize_to_tray Me.Visible = False End If End Sub
ใส่ที่ Module ครับ ...
Public 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 Public Const NIM_ADD = &H0 Public Const NIM_MODIFY = &H1 Public Const NIM_DELETE = &H2 Public Const WM_MOUSEMOVE = &H200 Public Const NIF_MESSAGE = &H1 Public Const NIF_ICON = &H2 Public Const NIF_TIP = &H4 Public Const WM_LBUTTONDBLCLK = &H203 Public Const WM_LBUTTONDOWN = &H201 Public Const WM_LBUTTONUP = &H202 Public Const WM_RBUTTONDBLCLK = &H206 Public Const WM_RBUTTONDOWN = &H204 Public Const WM_RBUTTONUP = &H205 Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
ไม่มีความคิดเห็น:
แสดงความคิดเห็น