|
-
Jan 25th, 2006, 03:38 PM
#1
Thread Starter
Addicted Member
Refresh Taskbar code
Hey. Does anyone have any code I could use to refresh the windows taskbar... specifically the area by the clock.
-
Jan 25th, 2006, 04:18 PM
#2
Hyperactive Member
Re: Refresh Taskbar code
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:
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&
Then, when you want to repaint the taskbar just use the following:
VB Code:
Dim taskbarHandle As IntPtr = FindWindow("SHELL_TRAYWND", String.Empty)
SendMessage(taskbarHandle, WM_PAINT, 0, 0)
That should (hopefully) do it.
"Make it idiot-proof and someone will make a better idiot"
-
Jan 27th, 2006, 11:56 AM
#3
Thread Starter
Addicted Member
Re: Refresh Taskbar code
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?
-
Jan 27th, 2006, 09:55 PM
#4
Re: Refresh Taskbar code
 Originally Posted by JohnRChick
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?
-
Jan 27th, 2006, 11:28 PM
#5
Thread Starter
Addicted Member
Re: Refresh Taskbar code
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|