views:

723

answers:

3

More particularly - I have a window handle of another running application. This application contains a TListControl.UnicodeClass control somewhere (I know this from Winspector). How can I, using the Windows API and that window handle, go through all the items in that list control and get the text from all of the items?

You can assume the language is C/C++, though I'll actually be using win32all for python. References to the appropriate API calls would be great.

A: 

You can get a handle on the control if you know the identifier constant.

In C, it's just this:

hControl = GetDlgItem(hWnd, IDENTIFIER)

Where hControl is your handle to the TListControl.UnicodeClass, hWnd is the window handle you claim to have, and IDENTIFIER is the identifier of the control. If you don't have that, I don't think the API will give you a handle to it.

Once you have the handle, using the control is documented very nicely.

Davis Gallinghouse
+2  A: 

You want EnumWindows and EnumChildWindows for the enumeration. See here for examples and usage info/warnings.

For window text, once you have the appropriate HWND, you want GetWindowText in general, and control-specific API's if the text is stored in a different place (eg: list controls). For the specific control, you will need to know the specific API, and it may not be available though just Windows API calls (for example, controls with owner-draw items can store their text in the app, not accessible to Windows).

Nick
+2  A: 

Above answers are completely wrong and don't even know what is a PAS. This has been answered hundreds of times for 20 years on Usenet. You must use IPC of course (RPM)

ask on news://comp.os.ms-windows.programmer.win32 for code.

PAS - publicly available spec? IPC - inter process communcation, RPM - ??. too many acronyms
Claudiu
or maybe pas is a pascal file?
Claudiu
anyway, a bit rude, but your answer is correct
Claudiu