VB6不会残留图标托盘

| |
[ 2019/12/27 00:33 | by admin ]
建立托盘命名为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
VB6编程 | 评论(0) | 引用(0) | 阅读(2727)
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
昵称   密码   游客无需密码
网址   电邮   [注册]
               

验证码 不区分大小写