|
-
Jun 13th, 2003, 02:19 AM
#1
Thread Starter
Lively Member
FindWindowEx "qwerk"
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:
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
However, when I added to it to look like the following:
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
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)
-
Jun 13th, 2003, 06:46 AM
#2
Use vbNullString instead of ""
VB Code:
Dim tmpWnd&
tmpWnd = FindWindow("Shell_TrayWnd", vbNullString) 'Task bar
tmpWnd = FindWindowEx(tmpWnd, 0&, "TrayNotifyWnd", vbNullString) 'System tray
trayclock = FindWindowEx(tmpWnd, 0&, "TrayClockWClass", vbNullString) 'System tray clock
MsgBox trayclock
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jun 14th, 2003, 01:06 AM
#3
Thread Starter
Lively Member
***?
Why does vbNullString make it work when "" doesn't?
-
Jun 14th, 2003, 05:17 AM
#4
Because a null string is much different than an empty string. vbNullString doesn't point to anything in memory.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jun 17th, 2003, 01:27 PM
#5
Hyperactive Member
VB Code:
ShellTrayWnd& = FindWindow("Shell_TrayWnd", vbNullString)
TrayNotifyWnd& = FindWindowEx(ShellTrayWnd&, 0&, "TrayNotifyWnd", vbNullString)
TrayClockWClass& = FindWindowEx(TrayNotifyWnd&, 0&, "TrayClockWClass", vbNullString)
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
|