Alex
Alex

Reputation: 2382

Issue with EnumWindows

When enumerating windows using EnumWindows, I get hundreds of handles instead of one per open window on my desktop.

First of all, i am curious if this is the correct behavior.

Secondly, trying to get a difference between open windows before and after launching a process returns 15-20 new handles. I am wondering if there is a way to filter these based on some flag, i really need just the mainwindow handle.

Any ideas?

Upvotes: 0

Views: 7097

Answers (2)

Alex K.
Alex K.

Reputation: 175956

You can filter within the enum callback by checking IsWindowVisible() & ignoring invisible system/message sink windows.

Upvotes: 0

SLaks
SLaks

Reputation: 888185

To get the main window of a process, use the Process.MainWindowHandle property.

To answer your question, you can see exactly what all of the handles are using Spy++.
In short, many applications will create hidden windows to run message loops.

Upvotes: 1

Related Questions