Option Explicit
Const MAX_TOOLTIP As Integer = 64
Const nif_icon = &H2
Const nif_message = &H1
Const nif_tip = &H4
Const niM_add = &H0
Const nim_delete = &H2
Const wm_mousemove = &H200
Const wm_lbuttondown = &H201
Const wm_lbuttonup = &H202
Const wm_lbuttonblclk = &H203
Const wm_rbuttondown = &H204
Const wm_rbuttonup = &H205
Const wm_rbuttondblclk = &H206
Const sw_restore = 9
Const sw_hide = 0
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As LongPrivate Declare Function Shell_NotifyIconA Lib "shell32.dll" Alias " Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As LongPrivate 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 nfIconData As NOTIFYICONDATAPrivate Sub Command1_Click()
nfIconData.hwnd = Me.hwnd
nfIconData.uID = Me.Icon
nfIconData.uFlags = nif_icon Or nif_message Or nif_tip
nfIconData.uCallbackMessage = wm_mousemove
nfIconData.hIcon = Me.Icon.Handle
nfIconData.szTip = "system tray example" & vbNullChar
nfIconData.cbSize = Len(nfIconData)
Call Shell_NotifyIconA(niM_add, nfIconData)
End SubPrivate Sub Command2_Click()
Call Shell_NotifyIconA(nim_delete, nfIconData)
End SubPrivate Sub Command3_Click()
ShowWindow Me.hwnd, sw_hide
End SubPrivate Sub Command4_Click()
Call Shell_NotifyIcon(nim_delete, nfIconData)
End SubPrivate Sub Command5_Click()
Me.Visible = False
End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim lMsg As Single
lMsg = X / Screen.TwipsPerPixelX
If lMsg = wm_rbuttonup Or lMsg = wm_lbuttonup Then Me.PopupMenu sys
End Sub
Const MAX_TOOLTIP As Integer = 64
Const nif_icon = &H2
Const nif_message = &H1
Const nif_tip = &H4
Const niM_add = &H0
Const nim_delete = &H2
Const wm_mousemove = &H200
Const wm_lbuttondown = &H201
Const wm_lbuttonup = &H202
Const wm_lbuttonblclk = &H203
Const wm_rbuttondown = &H204
Const wm_rbuttonup = &H205
Const wm_rbuttondblclk = &H206
Const sw_restore = 9
Const sw_hide = 0
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As LongPrivate Declare Function Shell_NotifyIconA Lib "shell32.dll" Alias " Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As LongPrivate 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 nfIconData As NOTIFYICONDATAPrivate Sub Command1_Click()
nfIconData.hwnd = Me.hwnd
nfIconData.uID = Me.Icon
nfIconData.uFlags = nif_icon Or nif_message Or nif_tip
nfIconData.uCallbackMessage = wm_mousemove
nfIconData.hIcon = Me.Icon.Handle
nfIconData.szTip = "system tray example" & vbNullChar
nfIconData.cbSize = Len(nfIconData)
Call Shell_NotifyIconA(niM_add, nfIconData)
End SubPrivate Sub Command2_Click()
Call Shell_NotifyIconA(nim_delete, nfIconData)
End SubPrivate Sub Command3_Click()
ShowWindow Me.hwnd, sw_hide
End SubPrivate Sub Command4_Click()
Call Shell_NotifyIcon(nim_delete, nfIconData)
End SubPrivate Sub Command5_Click()
Me.Visible = False
End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim lMsg As Single
lMsg = X / Screen.TwipsPerPixelX
If lMsg = wm_rbuttonup Or lMsg = wm_lbuttonup Then Me.PopupMenu sys
End Sub
解决方案 »
- 哪里有VB.NET网站的源代码
- VB问题求助啊
- 求助:COM+组建安装错误"Error registering COM+ Application"
- 急!在线等!MSFLexGrid控件中要选择其中第二列和所有行的内容怎么表示呢?主要是将其录入到数据库对应的一个字段中!谢谢!
- SendMessage相关:实现自动控制、操作外部程序。
- Type自定义类型无法传入类
- 跟一家20多个人的美容美体店做一个顾客管理程序,提供所有顾客消费情况记录、指定顾客的消费记录查询、月收入统计等功能,开价多少?
- 小问题请各位帮帮忙!(立马结账)......
- 自定义数据类型的保存问题
- ADO,dim rs as adodb.recordset / rs=cn.execute(str) / rs.movelast, rs.moveprevious 报错说不支持。我想可能需要将游标类型设为动态,
- 怎样使自己的程序在按下ctrl+alt+del时看不到?
- 高手们,谁有本事进来看看!
Call Shell_NotifyIconA(niM_add, nfIconData)
Call Shell_NotifyIconA(nim_delete, nfIconData)
Call Shell_NotifyIcon(nim_delete, nfIconData)
Public Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias " Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
载程序中调用
Shell_NotifyIcon