Click to See Complete Forum and Search --> : how to grab the data stored in tree-view?


MXPguru
September 22nd, 2005, 04:07 AM
in my winapi program i want to grab all the text stored in tree-view of another running application. how can i do this?

Alex F
September 22nd, 2005, 05:39 AM
To get information from other process you need to use inter-process communication.
http://www.codeguru.com/Cpp/misc/misc/article.php/c3807/
This sample shows how to do this with listview. You can use this way to work with treeview.

MXPguru
September 25th, 2005, 06:01 AM
Check this code.


int tvhi;
tvhi = 263290;
HWND tvh;
tvh = (HWND)tvhi;

HTREEITEM tvroot;
tvroot = (HTREEITEM)SendMessage(tvh,TVM_GETNEXTITEM,TVGN_ROOT,0);

if(tvroot==NULL)
MessageBox(hWnd,"err1","asdf",MB_OK);

TVITEMEX itemobj;
itemobj.hItem = tvroot;
itemobj.mask = TVIF_HANDLE | TVIF_TEXT;
itemobj.pszText = new char[20];
itemobj.cchTextMax = 20;

if(!SendMessage(tvh,TVM_GETITEM,0,(LPARAM) &itemobj))
MessageBox(hWnd,"err2","asdf",MB_OK);
else
MessageBox(hWnd,(LPCTSTR)itemobj.pszText,"asdf",MB_OK);


263290 is the handle of a TreeView control present in another window. I'm getting the "err2" MessageBox. If I get the number of items in the TreeView by using the TVM_GETCOUNT message, it works fine. It gives me correct number of items. But why isn't it grabbing the attributes of root item i specify in mask?

kirants
September 26th, 2005, 12:39 AM
MXPguru, please do not post the same question in multiple threads. This is againstAcceptable Use Policy (http://www.jupitermedia.com/corporate/privacy/aup.html). If you do not receive any answers, bump the same thread, so it comes to the top.