Option ExplicitPrivate 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 TypePrivate Const NIM_ADD = &H0 Private Const NIM_MODIFY = &H1 Private Const NIM_DELETE = &H2 Private Const WM_MOUSEMOVE = &H200 Private Const NIF_MESSAGE = &H1 Private Const NIF_ICON = &H2 Private Const NIF_TIP = &H4Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean Dim NOTI As NOTIFYICONDATAPrivate Sub Form_Load() NOTI.cbSize = Len(NOTI) NOTI.hWnd = Picture1(0).hWnd NOTI.uId = 1& NOTI.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE NOTI.ucallbackMessage = WM_MOUSEMOVE NOTI.hIcon = Picture1(0).Picture NOTI.szTip = "动画图标" + Chr$(0) Shell_NotifyIcon NIM_ADD, NOTI Timer1.Enabled = True Me.Hide App.TaskVisible = False End SubPrivate Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) Timer1.Enabled = False NOTI.cbSize = Len(NOTI) NOTI.hWnd = Picture1(0).hWnd NOTI.uId = 1& Shell_NotifyIcon NIM_DELETE, NOTI End SubPrivate Sub exit_Click(Index As Integer) Unload Me End SubPrivate Sub picture1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single) If X = 512 Then Me.PopupMenu file End If End Sub Private Sub timer1_Timer() Static i As Long, img As Long NOTI.cbSize = Len(NOTI) NOTI.hWnd = Picture1(0).hWnd NOTI.uId = 1& NOTI.uFlags = NIF_ICON NOTI.hIcon = Picture1(i).Picture Shell_NotifyIcon NIM_MODIFY, NOTI Timer1.Enabled = True i = i + 1 If i = 2 Then i = 0 End If End Sub 编译后把它拖到启动栏中
留下Email,我给你一个例子。
[email protected]
cbSize As Long
hWnd As Long
uId As Long
uFlags As Long
ucallbackMessage As Long
hIcon As Long
szTip As String * 64
End TypePrivate Const NIM_ADD = &H0
Private Const NIM_MODIFY = &H1
Private Const NIM_DELETE = &H2
Private Const WM_MOUSEMOVE = &H200
Private Const NIF_MESSAGE = &H1
Private Const NIF_ICON = &H2
Private Const NIF_TIP = &H4Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Dim NOTI As NOTIFYICONDATAPrivate Sub Form_Load()
NOTI.cbSize = Len(NOTI)
NOTI.hWnd = Picture1(0).hWnd
NOTI.uId = 1&
NOTI.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
NOTI.ucallbackMessage = WM_MOUSEMOVE
NOTI.hIcon = Picture1(0).Picture
NOTI.szTip = "动画图标" + Chr$(0)
Shell_NotifyIcon NIM_ADD, NOTI
Timer1.Enabled = True
Me.Hide
App.TaskVisible = False
End SubPrivate Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Timer1.Enabled = False
NOTI.cbSize = Len(NOTI)
NOTI.hWnd = Picture1(0).hWnd
NOTI.uId = 1&
Shell_NotifyIcon NIM_DELETE, NOTI
End SubPrivate Sub exit_Click(Index As Integer)
Unload Me
End SubPrivate Sub picture1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If X = 512 Then
Me.PopupMenu file
End If
End Sub
Private Sub timer1_Timer()
Static i As Long, img As Long
NOTI.cbSize = Len(NOTI)
NOTI.hWnd = Picture1(0).hWnd
NOTI.uId = 1&
NOTI.uFlags = NIF_ICON
NOTI.hIcon = Picture1(i).Picture
Shell_NotifyIcon NIM_MODIFY, NOTI
Timer1.Enabled = True
i = i + 1
If i = 2 Then
i = 0
End If
End Sub
编译后把它拖到启动栏中