跳到主要内容

VB6不会残留图标托盘

·

建立托盘命名为Popup,再建立Picture1命名为Pic

 1Private Type NOTIFYICONDATA
 2    cbSize As Long
 3    hWnd As Long
 4    uId As Long
 5    uFlags As Long
 6    ucallbackMessage As Long
 7    hIcon As Long
 8    szTip As String * 64
 9End Type
10 
11Private Const NIM_ADD = &H0
12Private Const NIM_MODIFY = &H1
13Private Const NIM_DELETE = &H2
14Private Const WM_MOUSEMOVE = &H200
15Private Const NIF_MESSAGE = &H1
16Private Const NIF_ICON = &H2
17Private Const NIF_TIP = &H4
18 
19Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA"
20 (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
21Dim t As NOTIFYICONDATA
 1Private Sub Form_Load()
 2    t.cbSize = Len(t)
 3    t.hWnd = Pic.hWnd
 4    t.uId = 1&
 5    t.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
 6    t.ucallbackMessage = WM_MOUSEMOVE
 7    t.hIcon = Pic.Picture
 8    t.szTip = "红防安全吧" & Chr$(0) 
 9    Shell_NotifyIcon NIM_ADD, t
10End Sub
1'清理图标
2Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
3    t.cbSize = Len(t)
4    t.hWnd = Pic.hWnd
5    t.uId = 1&
6    Shell_NotifyIcon NIM_DELETE, t
7End Sub
1'弹出菜单
2Private Sub pic_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
3    If Hex(x) = "1E3C" Then
4        Me.PopupMenu Popup
5    End If
6End Sub
白日映照满天星
作者
白日映照满天星
订阅我频道让你站在上帝角度观察视野! QQ:3925993 有尝解决技术问题【备注你的问题】 🐑

阅读量:评论:
赞赏码图