Question Read data grid from external program?

nomaam

Member
Joined
Jul 4, 2004
Messages
12
Programming Experience
Beginner
Hello:

I am working in windows forms with Vb.NET 2008

I am trying to read text in from an external program. So far I have been able to read text in from a standard text box or button, however I am trying to read data in from an external data grid.

When I try to use the following I get no information about the grid

ChildHandle = FindWindowEx(ParentHandle, IntPtr.Zero, "classnameofexternaldatagrid", Nothing)
Dim Hndl As IntPtr = Marshal.AllocHGlobal(2000)
NumText = SendMessage(ChildHandle, WM_GETTEXT, 2000, Hndl)
Text = Marshal.PtrToStringUni(Hndl)

Usually if it is a standard text box I will get the text data with no problem, but it is a standard data grid and there are no further sub handles to try and read from.

If WM_GETTEXT wont read information from an external data grid then how would I read in the data?

Any help would be great, thanks.
 
I suggest that you use one or more tools like Spy++, WinID and Winspector to examine the actual window structure. It's not really likely that a grid is going to have a single text value to represent all the data. You're probably going to have to go cell by cell.
 
I have been using Spy++ but it will not grab the handle within a data grid.

Here is the view i get with Spy++

spyxx | Flickr - Photo Sharing!

It will show the data grid as a list and then one child window as the headers. When I try to grab any text from those handles I get nothing. I do not know how to access the cells.

I then tried WinSpy++ and got the same results.

winspyxx | Flickr - Photo Sharing!

Above is the image when trying to grab child data from the header handle.

I then tried WinID and hovered the inquiry mouse point over the data grid. Below is an image of what data readings I got.

winid | Flickr - Photo Sharing!

I then tried Visual UIA Verify to examin the data grid. The program does display some more information about the data grid but I do not know how to access the cell data through VB.Net

VisualUIAutoVerify | Flickr - Photo Sharing!

The image shows a list of check boxes, the check boxes are within the first cell of the data grid so I would be able to access the entire row based on the first cell it would be great, but it will not drill down any further than the first cell. The data grid is comprised of about 6 coloumns and 6 rows.

The image also shows the column row titles, but again no ability to drill down.

Any thoughts? I'm at a loss on how to grab the cell data from the data table.

Thanks.
 
Most grids just draw the individual cells using the device context of the control.
So for most grids there is no way to drill down to the cell controls, because there are none.
Exception is a grid in edit mode (most editable grids use controls placed over a cell for input).

If you're lucky, your grid is a wrapper for a (non-virtual) windows listview.
There are ways to get to the items of a listview, even those in another process.
Don't know about the sub-items though.

As the classname of the control seems to be "TListView", I suspect your program is written in Embarcadero Delphi or Embarcadero C++Builder.
TListView is a Delphi-VCL wrapper for a windows listview.

Personally I'd rather find another way to retrieve the presented data.
Maybe you can contact the author of the other program?
 
Back
Top