退出程序时,托盘还在,鼠标移上去才消失。怎么解决
退出程序时,托盘还在,鼠标移上去才消失。怎么样才可以一退出。托盘也马上退出。
怎么解决。我用了以下代码还是不行。请高手帮忙。
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" _
(lpVersionInformation As OSVERSIONINFO) As Long
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
OsName As String
End Type
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Const WM_MOUSEMOVE = &H200
Private Function GetSysTrayWnd() As Long
Dim Result As Long
Dim Ver As OSVERSIONINFO
Ver.dwOSVersionInfoSize = 148
GetVersionEx Ver
Result = FindWindow("Shell_TrayWnd", vbNullString)
Result = FindWindowEx(Result, 0, "TrayNotifyWnd", vbNullString)
If Ver.dwMajorVersion = 5 And Ver.dwMinorVersion > 0 Then Result = FindWindowEx(Result, 0, "SysPager", vbNullString)
If Ver.dwMajorVersion = 5 Then Result = FindWindowEx(Result, 0, "ToolbarWindow32", vbNullString)
GetSysTrayWnd = Result
End Function
Private Sub RefreshTrayIcon()
Dim hwndTrayToolBar As Long
Dim X, Y As Long
Dim rTrayToolBar As RECT
Dim pos As Long
hwndTrayToolBar = GetSysTrayWnd
GetClientRect hwndTrayToolBar, rTrayToolBar
For X = 1 To rTrayToolBar.Right - 1
For Y = 1 To rTrayToolBar.Bottom - 1
pos = (X And &HFFFF) + (Y And &HFFFF) * &H10000
PostMessage hwndTrayToolBar, WM_MOUSEMOVE, 0, pos
Next
Next
End Sub
Private Sub Command1_Click()
RefreshTrayIcon
End Sub
Private Sub Form_Load()
End Sub