CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 3 of 4 FirstFirst 1234 LastLast
Results 31 to 45 of 58

Thread: I need Taskbar APIs

  1. #31
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,268

    Re: I need Taskbar APIs

    It seems like we have the same predicament
    I've been able to just about anything with the desktop settings, like, as I have it, it can actually replace the Desktop Properties. I further did just about anything with the computer icons, control panel items, start button and start menu.

    The taskbar has been the biggest headache for me, especially the clock ( same as you ). If you have followed this thread from the beginning, you'd see some easy and complicated stuff, and that I want to know how things work, but the clock is driving me nuts!!

    I'll also keep poking at it, but I don't promise anything . But when I do find something useful, I'll post

    PS: You really don't want to know how complicated it is working with the Quick Launch toolbar settings in the registry
    [SIGPIC][/SIGPIC]
    All my Articles
    Hannes

  2. #32
    Join Date
    Aug 2007
    Location
    Illinois
    Posts
    164

    Re: I need Taskbar APIs

    Quote Originally Posted by AltF4
    I really need to find some other method to try and inform explorer to reload and update the taskbar.
    I don't know if this will work...
    Instead of sending/posting a WM_SettingChange message, try the age-old "TaskbarCreated" mesage. From XP on down (don't have Vista to test), whenever explorer restarts, that message is sent to all top level windows so that they may re-add items to the systray and perform other tasks. To get the message value, you would call RegisterWindowMessage("TaskbarCreated") and pass the return value instead of WM_SettingChange.
    Insomnia is a simple byproduct of "it can't be done"

  3. #33
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,268

    Re: I need Taskbar APIs

    SendMessageTimeOut will not work with the Taskbar, or so it seems.
    LaVolpe, I think you're on the right track with SendMessage.

    Why don't we try using SendMessage, and sending a WM_PAINT event to the TrayWindow ¿
    [SIGPIC][/SIGPIC]
    All my Articles
    Hannes

  4. #34
    Join Date
    Apr 2007
    Posts
    66

    Re: I need Taskbar APIs

    Quote Originally Posted by WizBang
    Although I've not tried to do such as what you are looking for, here are a few things which come to mind.

    Some APIs:
    RedrawWindow
    SetWindowPos - NOT using NOSIZE, but using the current values for width and height
    Refreshing the desktop: http://msdn2.microsoft.com/en-us/library/ms723239.aspx
    Another desktop refresh method: http://vbnet.mvps.org/index.html?cod...eenrefresh.htm

    Perhaps something in the above will spark an idea, or not. I recall there's an API to redraw, refresh, or otherwise update the desktop, but whatever it was escapes me ATM. I'll look around later...

    RedrawWindow would perhaps be something to take a look at. Here is the MSDN link for it:
    http://msdn2.microsoft.com/en-us/library/ms534900.aspx

    SetWindowPos I might try with a combination of Redraw Window to see if it has hany effect.

    Refreshing the desktop I am pretty sure deals with either RefreshPolicyEx or SendMessage with the HWND_BROADCAST with the WM_SETTINGCHANGE message

    The other way described by vbnet uses this as a key to refreshing:
    Code:
                   Call SendMessageTimeout(HWND_BROADCAST, _
                                           WM_SETTINGCHANGE, _
                                           SPI_SETNONCLIENTMETRICS, _
                                           0&, SMTO_ABORTIFHUNG, _
                                           10000&, success)
    Which I have already tried with similar calls, but without success =[


    But keep up the suggestions.

    Ill have to try that RedrawWnidow that might work.

    Here is an interesting link that might help with window refreshing:
    http://www.codeguru.com/forum/archiv.../t-150081.html
    I havnt analyzed the code properly to figure ot exactly what is going on, but it might be helpful in our quest do refresh this taskbar programmatically.


    This might be our solution: (I will test this when I get home)
    http://translate.google.com/translat...yWnd%26hl%3Den


    Taskbar Resize:
    http://www.eggheadcafe.com/forumarch...st25368360.asp

    EE Answer to problem:
    http://209.85.165.104/search?q=cache...lnk&cd=3&gl=us



    EDIT:

    Ok so I tested this, but apparently this code just moves the mouse to update the system tray. Grrrr
    Last edited by AltF4; October 9th, 2007 at 03:23 PM.

  5. #35
    Join Date
    Apr 2007
    Posts
    66

    Re: I need Taskbar APIs

    Any New Ideas?

  6. #36
    Join Date
    Dec 2001
    Posts
    6,332

    Re: I need Taskbar APIs

    Well, I had uploaded an example of how to apply text to the background of an MDI form, in which I recall using some method for refreshing the window where the text is drawn. Perhaps such a technique can be used on the taskbar. I'm sure a search will locate my post on the MDI thing.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  7. #37
    Join Date
    Apr 2007
    Posts
    66

    Re: I need Taskbar APIs

    Any news/ new ideas yet?

  8. #38
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,268

    Re: I need Taskbar APIs

    AltF4, have you read post 33 ¿ - Guess not. Have you tried any of my advice ¿
    [SIGPIC][/SIGPIC]
    All my Articles
    Hannes

  9. #39
    Join Date
    Apr 2007
    Posts
    66

    Re: I need Taskbar APIs

    Quote Originally Posted by HanneSThEGreaT
    AltF4, have you read post 33 ¿ - Guess not. Have you tried any of my advice ¿

    Yes I did a while back. I am pretty sure it will not work though. Have u tried it yet?

  10. #40
    Join Date
    Aug 2007
    Location
    Illinois
    Posts
    164

    Re: I need Taskbar APIs

    Quote Originally Posted by AltF4
    Any new ideas?
    Have you tried using "TaskBarCreated" message as suggested in #33?
    Insomnia is a simple byproduct of "it can't be done"

  11. #41
    Join Date
    Apr 2007
    Posts
    66

    Re: I need Taskbar APIs

    Quote Originally Posted by LaVolpe
    Have you tried using "TaskBarCreated" message as suggested in #33?

    Ok here is what I have tried so far: (But still does not properly update the clock)

    It works awesome on other things under:
    HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced

    Example:
    TaskbarGlomming
    Start_ShowRun
    etc...

    (The other stuff under this key is updated with RefreshPolicyEx just if anyone was wondering)


    But it just wont work for taskbar stuff in the:

    HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2


    Code Attempt:
    (Just copy and paste these 2 blocks into a form and add 1 button and 1 list.)

    Note: You can test this with those 2 reg files below.

    General:
    Code:
                                        
    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 FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    
    Private Declare Function RedrawWindow Lib "user32" (ByVal hwnd As Long, lprcUpdate As Long, ByVal hrgnUpdate As Long, ByVal fuRedraw As Long) As Long
    
    
    Private Const RDW_INVALIDATE = &H1
    Private Const RDW_ERASE = &H4
    Private Const RDW_UPDATENOW = &H100
    
    Private Const RDW_ALLCHILDREN = 128
    Private Const RDW_FRAME = 1024
    
    
    
    Private Declare Function SendMessageTimeout Lib "user32" Alias "SendMessageTimeoutA" (ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As String, ByVal fuFlags As Long, ByVal uTimeout As Long, lpdwResult As Long) As Long
        Private Const SMTO_NOTIMEOUTIFNOTHING = &H8&
        
        Private Const WM_PAINT = 15
        Private Const WM_SETTINGCHANGE = &H1A&
        
        Private Const HWND_BROADCAST = &HFFFF&
    
    'Private Declare Function InvalidateRect Lib "user32" (ByVal hwnd As Long, lpRect As Long, ByVal bErase As Long) As Long
    
    Private Declare Function InvalidateRect Lib "user32" (ByVal hwnd As Long, lpRect As Any, ByVal bErase As Long) As Long
    Private Declare Function UpdateWindow Lib "user32" (ByVal hwnd As Long) As Long
    
    Private Declare Function SendNotifyMessage Lib "user32" Alias "SendNotifyMessageA" (ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" (ByVal lpString As String) As Long
    
    Private iCount As Integer
    Sub:
    Code:
    Private Sub Command1_Click()
    
        Call ClearOutput
    
    
        Dim ShellTrayWnd As Long: ShellTrayWnd = FindWindow("Shell_TrayWnd", vbNullString)
        Dim ClockWin As Long: ClockWin = FindWindowEx(FindWindowEx(ShellTrayWnd, 0, "TrayNotifyWnd", ""), 0, "TrayClockWClass", vbNullString)
        
        OutputReturn ShellTrayWnd
        OutputReturn ClockWin
        '-----
        
        
        '---
        'Taskbar Window:
        
        OutputReturn (RedrawWindow(ShellTrayWnd, 0, 0, RDW_INVALIDATE Or RDW_ALLCHILDREN Or RDW_FRAME Or RDW_UPDATENOW))
        
        
        'SendMessageTimeout HWND_BROADCAST, WM_PAINT, 0, vbNullString, SMTO_NOTIMEOUTIFNOTHING, 1000, 0
        OutputReturn SendMessageTimeout(ShellTrayWnd, WM_PAINT, 0, vbNullString, SMTO_NOTIMEOUTIFNOTHING, 1000, 0)
        OutputReturn SendMessageTimeout(ShellTrayWnd, WM_SETTINGCHANGE, 0, vbNullString, SMTO_NOTIMEOUTIFNOTHING, 1000, 0)
        
        
        OutputReturn InvalidateRect(ShellTrayWnd, ByVal 0, 0)
        OutputReturn UpdateWindow(ShellTrayWnd)
        
        
        
        '---
        'Clock Window:
        
        
        OutputReturn RedrawWindow(ClockWin, 0, 0, RDW_INVALIDATE Or RDW_ALLCHILDREN Or RDW_FRAME Or RDW_UPDATENOW)
        
        
        'SendMessageTimeout HWND_BROADCAST, WM_PAINT, 0, vbNullString, SMTO_NOTIMEOUTIFNOTHING, 1000, 0
        OutputReturn SendMessageTimeout(ClockWin, WM_PAINT, 0, vbNullString, SMTO_NOTIMEOUTIFNOTHING, 1000, 0)
        OutputReturn SendMessageTimeout(ClockWin, WM_SETTINGCHANGE, 0, vbNullString, SMTO_NOTIMEOUTIFNOTHING, 1000, 0)
        
        
        OutputReturn InvalidateRect(ClockWin, ByVal 0, 0)
        OutputReturn UpdateWindow(ClockWin)
        
        
        
        '---
        OutputReturn SendNotifyMessage(HWND_BROADCAST, RegisterWindowMessage("TaskbarCreated"), 0, 0)
        'http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1427677&SiteID=1
        
        
        
        '-----------
        'Notes:
        '   Sending WM_SETTINGCHANGE to taskbar ("Shell_TrayWnd") updates TaskbarGlomming (HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced)
    
        
    
    End Sub
    
    Private Sub ClearOutput()
        List1.Clear
        iCount = 0
    End Sub
    
    
    Private Sub OutputReturn(ByVal sString As String)
        iCount = iCount + 1
        
        Call List1.AddItem(iCount & "." & vbTab & sString)
    End Sub
    I have tested this with these two .reg files which I know work, because if I add either of them to the registry, kill explorer.exe and restart it, the clock is either shown or hidden:


    show clock.reg
    Code:
    Windows Registry Editor Version 5.00
    
    [HKEY_USERS\S-1-5-21-1390067357-1563985344-839522115-1003\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2]
    "Settings"=hex:28,00,00,00,ff,ff,ff,ff,02,00,00,00,03,00,00,00,6b,00,00,00,1e,\
      00,00,00,00,00,00,00,92,04,00,00,40,06,00,00,b0,04,00,00
    @=""
    hide clock.reg
    Code:
    Windows Registry Editor Version 5.00
    
    [HKEY_USERS\S-1-5-21-1390067357-1563985344-839522115-1003\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2]
    "Settings"=hex:28,00,00,00,ff,ff,ff,ff,0a,00,00,00,03,00,00,00,6b,00,00,00,1e,\
      00,00,00,00,00,00,00,92,04,00,00,40,06,00,00,b0,04,00,00
    @=""

    The difference between them is the 02 (show) and 0a (hide) after the ff,ff,ff,ff.

    Again, these work as intended, but the problem is in getting the code to work.


    Here is some stuff I have been trying to uderstand and experiment with:
    http://msdn2.microsoft.com/en-us/library/ms534858.aspx

    It is MSDNs Article on window drawing and GUI stuff.
    If you look on the left sidebar the Painting and Drawing Reference contains many useful API, Constants, and Structures I have been trying to play with to get this mofo to update.

    Well If you have anymore Ideas please post.


    dämn you explorer.exe
    Last edited by AltF4; October 20th, 2007 at 12:48 PM.

  12. #42
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: I need Taskbar APIs

    Shame I'm not of great help here (being not my corner), but since I follow this thread with interest I feel like commenting on it. You guys seem to dig up a lot of interesting information there. Do get on with it.

  13. #43
    Join Date
    Dec 2001
    Posts
    6,332

    Re: I need Taskbar APIs

    Just a thought:

    Suppose you were to shell the applet which normally handles the settings? Doing so with the window hidden. Might that work? I know it's not necessarily an ideal method, but if all else fails...
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  14. #44
    Join Date
    Apr 2007
    Posts
    66

    Re: I need Taskbar APIs

    Maybe I can work with resizing the rectangle to a hidden state.

    I could of course always just hide the window, but it appears as if something was there but missing. Resizing the rectangle could give the the allusion that the restriction is in place or is hidden.

    Although this isn't what exactly I planned to do. I really want to try and update explorer properly. A method to do so can be very powerful to fully update your system without logging off, saving time, and allow you to better troubleshoot problems.

    It seems that RefreshPolicyEx and sending WM_SETTINGCHANGE is a wonderful combination in refreshing most of the features that can be applied in GP or even just check boxes that are manually applied through the registry. Yet this is still a mystery on how to properly update explorer.exe fully.

  15. #45
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,268

    Re: I need Taskbar APIs

    Quote Originally Posted by AltF4
    I am pretty sure it will not work though
    Why not, I really think it may have worked, the problem that we "have created ourselves" is to stare us blind against the fact that we need to update the explorer.exe. That proved wrong, as you would agree, because we need to update the systemtray ( systray.exe ) - Glad to see that you have use the StruckRects2 key, which is the correct key.

    Quote Originally Posted by WoF
    Shame I'm not of great help here (being not my corner), but since I follow this thread with interest I feel like commenting on it. You guys seem to dig up a lot of interesting information there. Do get on with it.
    Thanx, and I've learnt a great deal also

    Quote Originally Posted by WizBang
    Just a thought:

    Suppose you were to shell the applet which normally handles the settings? Doing so with the window hidden. Might that work? I know it's not necessarily an ideal method, but if all else fails...
    Good idea! Initially I wanted to take that route, but I guess I got so caught up with all the API stuff and the Registry keys . Just one thing though, shelling it with vbHide, didn't hide it, it just set the window to the back, so that didn't have much effect, unless I've implemented it wrong.

    This is what I did, based on WizBang's comment :
    Code:
    Option Explicit
    
    Private Sub Command1_Click()
    'run the taskbar properties applet
    Dim x As Long
    x = Shell("rundll32.exe shell32.dll,Options_RunDLL 1", vbNormalFocus)
    End Sub
    
    Private Sub Command2_Click()
    'send alt + tab to activate the taskbar properties window
    SendKeys "%{tab}"
    'send the "Show the clock keyboard shortcut - Alt + k"
    SendKeys "%k", True
    'sen enter to automatically click the OK button in taskbar properties
    SendKeys "{enter}"
    End Sub
    In Button 1, I shell the Taskbar properties dialog
    In button 2, I send Alt + tab, to make that window the active window ( else it won't get the key input we want to send )
    Next, I send the "Show clock" shortcut ( Alt + K ), then lastly,
    I send the Enter to Apply and close the box.

    This happens extremely fast, and it does indeed work perfectly.
    I'll settle for this, because I'm really out of more ideas on updating the system tray. So to me, I can finally move on with the next part of that program ( which is to manipulate the Quick Launch toolbar ) Hopefully it will be done soon enough ( because I plan to write an rticle about this ).

    Thanx for all your help / input / comments!

    And yeah, I'm back
    [SIGPIC][/SIGPIC]
    All my Articles
    Hannes

Page 3 of 4 FirstFirst 1234 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)