Hey. Does anyone have any code I could use to refresh the windows taskbar... specifically the area by the clock.
Printable View
Hey. Does anyone have any code I could use to refresh the windows taskbar... specifically the area by the clock.
The taskbar is simply a window like any other. As long as you know the window class name you can use the SendMessage API with the WM_PAINT parameter to force the taskbar to repaint itself. The class name is "SHELL_TRAYWND":
Use the following declarations:
Then, when you want to repaint the taskbar just use the following:VB Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByRef lParam As Integer) As Integer Private Const WM_PAINT As Integer = &HF&
That should (hopefully) do it. :thumb:VB Code:
Dim taskbarHandle As IntPtr = FindWindow("SHELL_TRAYWND", String.Empty) SendMessage(taskbarHandle, WM_PAINT, 0, 0)
hey. Thanks for the code. I tried it, but it doesnt really do anything. I set it to run when my program loads, and it doesnt remove any tray icons that are actually not running from my other program. Any ideaS?
Are you sure they're not running? and why not properly remove them from your other applicaitons when they're done running?Quote:
Originally Posted by JohnRChick
its a long story, because i have this code that i use to close all my applications... but i cant use the .closemainwindow because the apps arent show in the taskbar... Therefore the .closing() code doesnt run and in there is the code to unshow the trayicon. So each time the app runs i want ti to refresh the taskbar incase.