Flafy
Flafy

Reputation: 335

2 Windows with the same name and class

I have 2 windows with the same class and name. Here is a picture of the 2 windows in SPY++

the 2 windows

I want to find the bottom window(001C1E1A) But whenever I'm trying to find him using this line:

hwndChild2 = FindWindowEx((IntPtr)hwndChild, IntPtr.Zero, "msctls_progress32", null);

I get the top window(00790B50) instead.

So my question is: How can I find the bottom window(001C1E1A) from the list in the picture?

Upvotes: 0

Views: 318

Answers (1)

René Vogt
René Vogt

Reputation: 43876

According to documentation the first argument of FindWindowEx is the parent window, and the second parameter is childAfter, the handle of the window you found before.

So these calls should give you the result:

// find first window
hwndChild = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "msctls_progress32", null);
// find second window
hwndChild2 = FindWindowEx(IntPtr.Zero, (IntPtr)hwndChild, "msctls_progress32", null);

Upvotes: 3

Related Questions