诸位,谁有VB做托盘程序的例子?给我来一份。

解决方案 »

  1.   

    http://www.csdn.net/cnshare/soft/16/16015.shtm
      

  2.   

    http://www.hongen.com/pc/program/apitutor/api0012/api01.htm
    http://www.yesky.com/20011024/202037.shtml
      

  3.   

    Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
    Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hwnd&, ByVal nIndex&, ByVal dwNewLong&)
    Public Const WM_LBUTTONDBLCLK = &H203
    Public Const WM_RBUTTONUP = &H205
    Public Const WM_LBUTTONDOWN = &H201
    Public Const WM_LBUTTONUP = &H202
    Public Const NIM_ADD = &H0
    Public Const NIM_MODIFY = &H1
    Public Const NIF_MESSAGE = &H1
    Public Const NIM_DELETE = &H2
    Public Const NIF_ICON = &H2
    Public Const NIF_TIP = &H4
    Public Const WM_MOUSEMOVE = &H200
    Public 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
    Public TrayIcon As NOTIFYICONDATA
    Sub Systray_Load(thisForm As Form, pic As Picture)
         TrayIcon.cbSize = Len(TrayIcon)
        TrayIcon.hwnd = thisForm.hwnd
        TrayIcon.uid = vbNull
        TrayIcon.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
        TrayIcon.ucallbackMessage = WM_MOUSEMOVE
        TrayIcon.hIcon = pic
        TrayIcon.szTip = "Menu" & vbNullChar
        Call Shell_NotifyIcon(NIM_ADD, TrayIcon)
        App.TaskVisible = False
    End Sub
    Sub Systray_Unload(Frm As Form)
    On Error GoTo aaaa
        Call SetWindowLong(Frm.hwnd, GWL_WNDPROC, procOld)
        TrayIcon.cbSize = Len(TrayIcon)
        TrayIcon.hwnd = Frm.hwnd
        TrayIcon.uid = vbNull
        Call Shell_NotifyIcon(NIM_DELETE, TrayIcon)
    aaaa:
    End Sub
      

  4.   

    http://www.dapha.net/down/list.asp?id=1565
    http://www.dapha.net/down/list.asp?id=1549
    http://www.dapha.net/down/list.asp?id=172
    http://www.dapha.net/down/list.asp?id=165
    http://www.dapha.net/down/list.asp?id=173
      

  5.   

    Option ExplicitPrivate 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 WM_LBUTTONDOWN = &H201
    Private Const WM_LBUTTONDBLCLK = &H203
    Private Const WM_RBUTTONUP = &H205
    Private Const NIM_ADD = &H0
    Private Const NIM_MODIFY = &H1
    Private Const NIF_MESSAGE = &H1
    Private Const NIM_DELETE = &H2
    Private Const NIF_ICON = &H2
    Private Const NIF_TIP = &H4
    Private Const WM_MOUSEMOVE = &H200Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
    Private Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd As Long) As Long
    Dim TrayIcon As NOTIFYICONDATAPrivate Sub Form_Load()
        TrayIcon.cbSize = Len(TrayIcon)
        TrayIcon.hWnd = hWnd
        TrayIcon.uId = vbNull
        TrayIcon.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
        TrayIcon.ucallbackMessage = WM_MOUSEMOVE
        TrayIcon.hIcon = Me.Icon
        TrayIcon.szTip = "拖盘" & Chr(0)
        
        '在系统栏添加拖盘
        Call Shell_NotifyIcon(NIM_ADD, TrayIcon)
    End SubPrivate Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
        '构造系统拖盘结构
        TrayIcon.cbSize = Len(TrayIcon)
        TrayIcon.hWnd = Me.hWnd
        TrayIcon.uId = vbNull
        
        '删除系统栏的拖盘
        Call Shell_NotifyIcon(NIM_DELETE, TrayIcon)
    End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    On Error Resume Next
        Dim Message As Long
        
        Message = X / Screen.TwipsPerPixelX    '判断鼠标消息,执行不同的功能
        Select Case Message
          Case WM_LBUTTONDOWN
              '点击拖盘
          Case WM_RBUTTONUP
              SetForegroundWindow Me.hWnd
              '按右键弹出菜单
              'PopupMenu mnuPopup
        End Select
    End Sub