Results 1 to 5 of 5

Thread: Refresh Taskbar code

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2005
    Posts
    181

    Refresh Taskbar code

    Hey. Does anyone have any code I could use to refresh the windows taskbar... specifically the area by the clock.

  2. #2
    Hyperactive Member
    Join Date
    Mar 2005
    Location
    Bath, England
    Posts
    411

    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:
    1. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
    2. 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
    3. Private Const WM_PAINT As Integer = &HF&
    Then, when you want to repaint the taskbar just use the following:
    VB Code:
    1. Dim taskbarHandle As IntPtr = FindWindow("SHELL_TRAYWND", String.Empty)
    2. SendMessage(taskbarHandle, WM_PAINT, 0, 0)
    That should (hopefully) do it.
    "Make it idiot-proof and someone will make a better idiot"

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2005
    Posts
    181

    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?

  4. #4
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Refresh Taskbar code

    Quote 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?
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    May 2005
    Posts
    181

    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
  •  



Click Here to Expand Forum to Full Width