建立托盘命名为Popup,再建立Picture1命名为Pic
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 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 = &H4
Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA"
(ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Dim t As NOTIFYICONDATA
?复制代码
Private Sub Form_Load()
t.cbSize = Len(t)
t.hWnd = Pic.hWnd
t.uId = 1&
t.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
t.ucallbackMessage = WM_MOUSEMOVE
t.hIcon = Pic.Picture
t.szTip = "红防安全吧" & Chr$(0)
Shell_NotifyIcon NIM_ADD, t
End Sub
?复制代码
'清理图标
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
t.cbSize = Len(t)
t.hWnd = Pic.hWnd
t.uId = 1&
Shell_NotifyIcon NIM_DELETE, t
End Sub
?复制代码
'弹出菜单
Private Sub pic_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Hex(x) = "1E3C" Then
Me.PopupMenu Popup
End If
End Sub
本文链接:https://www.kinber.cn/post/4925.html 转载需授权!
推荐本站淘宝优惠价购买喜欢的宝贝: