Given HWND of a SysListView32, how do I get contents?

Years ago I knew some of this stuff, I've been away from it too log, apologies in advance for being so stupid...

Environment: Windows 7 x64, VS 2010 .NET

My question: Given the HWND of a control in a child window of some parent window, how do I actually get the control itself, to be able to manipulate it programatically?

For example - If I launch the Windows 7 Sound Dialog Panel, I can use EnumChildWindows() to get the HWND of the SysListView32 that displays all the available audio devices (in the first tab, "Playback"). Now, given the HWND of the SysListView32, how do I actually read the contents (specifically, all the text of all the elements) into my application? I want to select one of them and make it the current selection, but I can't know which one to select without examining the text. Once I have selected the device I want, I can message the "Apply" button (SendMessage(applyButton,BM_CLICK,0,0)) and destroy the dialog panel.

My intuition tells me the answer to this question is so simple it's coiled around my leg waiting to bite...


Somewhere on the net (,
searching for an answer, I came across this statement:

"Accessing the properties of an object means you need to have a
reference to the object. The hWnd is a property of the object, not the
other way around. So getting an object reference with the hWnd isn't
going to happen."

It doesn't sound promising. But at the same time something feels wrong. Microsoft
DELIBERATELY does not expose the API of the lower level semantic actions (methods)
that are invoked by the Sound Dialog applet (and others) because they fear registry
inconsistencies and a degraded user experience. They seem to encourage programmers
going through the GUI instead to do such things. So it must be possible, right?
Last edited on
Topic archived. No new replies allowed.