Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i get HWND of external application's listview? In Windows Api using c++

So i am trying to make app to get content of my explorer listviews and get item text etc.. from it but here are the problems...

If i inspect windows explorer folder(using spy++) with listview, just for testing purposes i will use random folder.

It shows me that caption of the window is "FolderView" with class "SysListView32" and the top level window where this listview is nested is called "reference", this is also the title of windows explorer folder where all the files are.

So what i do is..

HWND hWndLV = FindWindow(NULL, TEXT("reference")); // first i get hwnd of the main window, this is where listview window is also nested according to spy++, thats why i do this first.

HWND child = FindWindowEx(hWndLV, NULL,NULL,TEXT("FolderView")); // trying to get hwnd of the listview here but it fails, same happens if i also put the class name along as 

HWND child = FindWindowEx(hWndLV, NULL,TEXT("SysListView32"),TEXT("FolderView"));

I am using bool test = IsWindow(child); to test for fail, also VS debugger shows 0x0000000000 each time so i am sure i am reading results well.

So i am stuck on this probably simple thing for most of people:(

p.s. i am on vista64(if that matters anyhow)

edit: It appears that this function works only if i search the first nested level of a parent window i am searching. So i assume what i need is a way to get handle with some sort of deep nested level search.

I also tried to go step by step by defining hwnd of every parent then i use findwindowex on it but oh boy then i get to the point where there are 5 nested windows all with the same name and only one of them contains my listview, so nice uh?

like image 928
Marko29 Avatar asked Oct 14 '22 18:10

Marko29


1 Answers

If you got a handle to main window (using FindWindow for example), you can enumerate its child windows using EnumChildWindows.

like image 69
Vladimir Avatar answered Oct 18 '22 02:10

Vladimir