VB托盘图标问题
编写程序时可以把图标加载到右下角的托盘,但是退出时不会消失,什么代码可以使图标消失呢?
答案:字数太多,分次发出来
添加一个模块,把下面的代码复制进去
Public Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Type NOTIFYICONDATA
cbSize As Long '需填入NOTIFYICONDATA数据结构的长度
hWnd As Long '设置成窗口的句柄
Uid As Long '为图标所设置的ID值
UFlags As Long '设置uCallbackMessage,hIcon,szTip是否有效
UCallbackMessage As Long '消息编号
HIcon As Long '显示在状态栏上的图标
SzTip As String * 64 '提示信息
End Type
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
Public Const NIF_MESSAGE = &H1
Public Const NIM_ADD = 0 '加入图标到系统状态栏中
Public Const NIM_MODIFY = 1 '修改系统状态栏中的图标
Public Const NIM_DELETE = 2 '删除系统状态栏中的图标
Public Const WM_USER = &H400
Public Const WM_LBUTTONUP = &H202
Public Const WM_MBUTTONUP = &H208
Public Const WM_RBUTTONUP = &H205
Public Const TRAY_CALLBACK = (WM_USER + 1001&)
Public Const GWL_WNDPROC = (-4)
Public Const GWL_USERDATA = (-21)
上一个:VB问题组合
下一个:VB循环语句