在这里有http://www.csdn.net/Expert/memberInfo.asp?Roomid=2&typenum=8&tabletype=now&searchKeys=托盘&author=&whichpage=1
解决方案 »
- vb内存溢出问题
- 抓狂.散分
- vb怎么求一个动态一维数组的长度
- 各位大虾,vb随机生成4位随机数,怎么实现啊,送分啦
- vb 播放音乐的问题? 急啊!
- visualbasic的好坏。
- 和大家都相关的一个建议,欢迎讨论!
- VB中窗体的Borderstyle设为0-NONE.在程序运行时,显示在任务栏只有程序名称,而没有了图标,请问怎样才能使图标不丢失??
- 我用MDI制作记事本..可是做到查找功能时...弹出一个查找替换窗口..活动窗口就成了这个查找替换窗口..而不是我想要的新建的MDI子窗体..
- SubZero 您好,请讲一下MSCOMM的用法,及按您说的情况谈一下详细的编程思路。谢谢!
- 问一个超级简单的问题!!!!!
- 让我的程序支持ADDin?在线等待
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
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