在这里有http://www.csdn.net/Expert/memberInfo.asp?Roomid=2&typenum=8&tabletype=now&searchKeys=托盘&author=&whichpage=1

解决方案 »

  1.   

    这个问题我看过不下10次了,在www.21code.com有例子
      

  2.   

    这种例子太多了,google一下能找出一大堆
      

  3.   

    Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As BooleanPrivate Sub Form_Load()
        If App.PrevInstance Then
            BringWindowToTop Me.hwnd
            MsgBox "本程序已运行!"
            End '结束程序
        End If
        
        'centers form
        Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2    'sets cbSize to the Length of TrayIcon
        TrayIcon.cbSize = Len(TrayIcon)
        ' Handle of the window used to handle messages - which is the this form
        TrayIcon.hwnd = Me.hwnd
        ' ID code of the icon
        TrayIcon.uId = vbNull
        ' Flags
        TrayIcon.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
        ' ID of the call back message
        TrayIcon.ucallbackMessage = WM_MOUSEMOVE
        ' The icon - sets the icon that should be used
        'TrayIcon.hIcon = imgIcon1.Picture
        ' The Tooltip for the icon - sets the Tooltip that will be displayed
        TrayIcon.szTip = "180投诉处理系统" & Chr$(0)
        '图标为系统图标
        TrayIcon.hIcon = Image1.Picture
        ' Add icon to the tray by calling the Shell_NotifyIcon API
        'NIM_ADD is a Constant - add icon to tray
        Call Shell_NotifyIcon(NIM_ADD, TrayIcon)
        
        ' Don't let application appear in the Windows task list
        App.TaskVisible = False
        'Me.Hide
        Timer1.Interval = 1000 '扫描时间1*300秒
    End Sub
      

  4.   

    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 TypePrivate Const sglSplitLimit = 500Private 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 Const WM_LBUTTONDBLCLK = &H203
    Private Const WM_LBUTTONDOWN = &H201
    Private Const WM_LBUTTONUP = &H202
    Private Const WM_RBUTTONDBLCLK = &H206
    Private Const WM_RBUTTONDOWN = &H204
    Private Const WM_RBUTTONUP = &H205Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
    Dim t As NOTIFYICONDATA' 在窗體上放置Image控件加入妳要的圖標﹐假如名稱為imgOne
      放直一個Picture控件﹐命名為picHookPrivate Sub Form_Load()
       
       On Error Resume Next
        t.cbSize = Len(t)
        t.hwnd = picHook.hwnd
        t.uId = 1&
        t.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
        t.ucallbackMessage = WM_MOUSEMOVE
        t.hIcon = imgOne.Picture
        t.szTip = ProgramName & Chr$(0)
        Shell_NotifyIcon NIM_ADD, t
    end sub
    Private Sub picHook_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
     Static State As Boolean
     Static Popped As Boolean
     Static msg As Long
     
        msg = X / Screen.TwipsPerPixelX
        If Popped = False Then
            Popped = True
            
            Select Case msg
                ' 鼠標左鍵
                Case WM_LBUTTONDBLCLK
                    mnuPopupOpen_Click
                ' 鼠標左鍵
                Case WM_LBUTTONDOWN
                Case WM_LBUTTONUP
                
                Case WM_RBUTTONDBLCLK
                
                Case WM_RBUTTONDOWN
                
                Case WM_RBUTTONUP
                    PopupMenu mnuPopup, 2, , , mnuPopupOpen
                    
            End Select
            'OK to popup again
            Popped = False
        End If
    End Sub