×

VB6不会残留图标托盘

hqy hqy 发表于2025-02-21 16:12:01 浏览32 评论0

抢沙发发表评论

建立托盘命名为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 转载需授权!

分享到:


推荐本站淘宝优惠价购买喜欢的宝贝:

image.png

 您阅读本篇文章共花了: 0小时00分01秒

群贤毕至

访客
G