While trying to use the FindWindow (and FindWindowEx) APIs to get the hWnd for the SysTray clock, I ran into a problem. The original (and, for some strange reason, non-working) code is:
However, when I added to it to look like the following:VB Code:
Dim tmpWnd& tmpWnd = FindWindow("Shell_TrayWnd", "") 'Task bar tmpWnd = FindWindowEx(tmpWnd, 0&, "TrayNotifyWnd", "") 'System tray trayClock = FindWindowEx(tmpWnd, 0&, "TrayClockWClass", "") 'System tray clock
it works just fine. In fact, the first child of TrayNotifyWnd (the system tray) is the SysTray clock. Any idea why the first didn't work? (P.S. trayClock is a Public variable and I'm 100% positive that the SysTray clock's class name is TrayClockWClass, thanks to a "WindowSpy" example program I have)VB Code:
Dim tmpWnd&, clsName As String * 100, clsLen& tmpWnd = FindWindow("Shell_TrayWnd", "") 'Task bar tmpWnd = FindWindowEx(tmpWnd, 0&, "TrayNotifyWnd", "") 'System tray trayClock = FindWindowEx(tmpWnd, 0&, "TrayClockWClass", "") 'System tray clock If trayClock = 0 Then tmpWnd = GetWindow(tmpWnd, GW_CHILD) Do While tmpWnd <> 0 clsLen = GetClassName(tmpWnd, clsName, 100) If Left(clsName, clsLen) = "TrayClockWClass" Then trayClock = tmpWnd Exit Do End If tmpWnd = GetWindow(tmpWnd, GW_HWNDNEXT) Loop End If




Reply With Quote