Click here to Skip to main content
15,895,709 members
Please Sign up or sign in to vote.
4.33/5 (2 votes)
See more:
Hi, I'm always thank you.

Well, I've tried to get Process's Top Window Handle from Process name.
So I referred http://blog.daum.net/msgmap/15698241[^] and get Window Handle from Process name.

But retrieved Window Handle is not Top Window Handle of Process, it's first child window handle of process.

So I use FindWindow() API to get top Window Handle with it's class name and have solved this problem. But, whenever I didn't know the class name I didn't use FindWindow API.

Is there any solution to get Top Window Handle without using FindWinow API?

Please, help me.
Posted

Spy++ can does that all. Here is an open source version of Spy++. I am 100% sure that you can find what you're looking for if you go through all the code (just a few files).

From the link below:
Quote:
WinSpy++ can obtain the following window properties:

Window Class and Name.
Window procedure address.
All window styles and extended styles.
Window properties (set using the SetProp API call).
Complete Child and Sibling window relationships.
Scrollbar positional information.
Full window Class information.


http://www.catch22.net/software/winspy-17[^]
 
Share this answer
 
v2
Comments
WuRunZhe 24-Oct-13 20:19pm    
It's a great help for me. I've accept Spy++ source.
But there are two errors occurred during compiling.

XXX\BitmapButton.c(27) : fatal error C1083: Cannot open include file: 'uxtheme.h': No such file or directory
XXX\WinSpyWindow.c(21) : fatal error C1189: #error : "Please install latest Platform SDK or define WINVER >= 0x500"

How can I fix it.
Always believe your help.
Captain Price 25-Oct-13 1:38am    
Sorry, I haven't compiled it. But I'll look into it :)
WuRunZhe 25-Oct-13 8:37am    
Thank you.
hi,
maybe this helps :
GetTopWindow function[^]
and
Windows-SDK-What-is-a-top-level-window[^]

hope this helps!
 
Share this answer
 
Comments
WuRunZhe 24-Oct-13 8:24am    
Thanks for your help. The Method you have supported is just that get parent Window Handle from Child Window Handle which is retrieved from method where I've wrote.

You are right, but I just want to know get the top window handle without retrieving parent handle from child window and without retrieving FindWindow API.

Using FindWindow API with class name, it directly get process's top window handle. Just like this, I want to get Top Window Handle of Process directly.

Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900