VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This code is to reset the systray icon after explorer closes or crashes if you use a systray icon l

by Brent Smith (1 Submission)
Category: Windows System Services
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 4th September 2007
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This code is to reset the systray icon after explorer closes or crashes if you use a systray icon like most devloupers and find that you cant

API Declarations


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
Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim SystemTrayhWnd As Long


Rate This code is to reset the systray icon after explorer closes or crashes if you use a systray icon l



'ok here is a simple way to fix this 
'Use an api call such as send message
'Get the system tray handle 
'Check to see if the handle has changed 
'Reapply the icon if it has 
'temporally store the new handle to repeat the process 
'The code in VB6
Public Function getsystrayhwnd()
Dim shelltraywnd As Long
Dim traynotifywnd As Long
Dim trayclockwclass As Long
shelltraywnd = FindWindow("shell_traywnd", vbNullString)
traynotifywnd = FindWindowEx(shelltraywnd, 0&, "traynotifywnd", vbNullString)
trayclockwclass = FindWindowEx(traynotifywnd, 0&, "trayclockwclass", vbNullString)
If trayclockwclass = 0 Then
Exit Function
End If
If Not trayclockwclass = SystemTrayhWnd Then
SystemTrayhWnd = trayclockwclass
'call function to show icon
End If
End Function
'call this from a timer set for 5 seconds or some other event firing check 
Vb code is all i know how to write this in 


Download this snippet    Add to My Saved Code

This code is to reset the systray icon after explorer closes or crashes if you use a systray icon l Comments

No comments have been posted about This code is to reset the systray icon after explorer closes or crashes if you use a systray icon l. Why not be the first to post a comment about This code is to reset the systray icon after explorer closes or crashes if you use a systray icon l.

Post your comment

Subject:
Message:
0/1000 characters