MXPguru
September 25th, 2005, 01:56 PM
'tvh' holds the handle of the TreeView whose items' text I want to grab. The TreeView is of another application currently running. I get its handle through Spy++.
Check this code:
int tvhi;
tvhi = 0x000702A6;
HWND tvh;
tvh = (HWND)tvhi;
HTREEITEM tvroot;
tvroot = (HTREEITEM)SendMessage(tvh,TVM_GETNEXTITEM,TVGN_ROOT,0); // get root item
if(tvroot==NULL)
MessageBox(hWnd,"err1","asdf",MB_OK);
TVITEMEX itemobj;
itemobj.mask = TVIF_TEXT; // i've to retrieve text
itemobj.pszText = text;
itemobj.cchTextMax = 256;
itemobj.hItem = tvroot; // i've to work on root item
if(!SendMessage(tvh,TVM_GETITEM,0,(LPARAM)&itemobj)) // retrieve text
MessageBox(hWnd,"err2","asdf",MB_OK);
else
MessageBox(hWnd,itemobj.pszText,"asdf",MB_OK);
Now I'm getting the "err2" messagebox. If I send any other message, like to get number of items in treeview or to delete all items in treeview, it works fine. But if I do this to get text of the item, the SendMessage returns false.
Can anybody help, please?
Check this code:
int tvhi;
tvhi = 0x000702A6;
HWND tvh;
tvh = (HWND)tvhi;
HTREEITEM tvroot;
tvroot = (HTREEITEM)SendMessage(tvh,TVM_GETNEXTITEM,TVGN_ROOT,0); // get root item
if(tvroot==NULL)
MessageBox(hWnd,"err1","asdf",MB_OK);
TVITEMEX itemobj;
itemobj.mask = TVIF_TEXT; // i've to retrieve text
itemobj.pszText = text;
itemobj.cchTextMax = 256;
itemobj.hItem = tvroot; // i've to work on root item
if(!SendMessage(tvh,TVM_GETITEM,0,(LPARAM)&itemobj)) // retrieve text
MessageBox(hWnd,"err2","asdf",MB_OK);
else
MessageBox(hWnd,itemobj.pszText,"asdf",MB_OK);
Now I'm getting the "err2" messagebox. If I send any other message, like to get number of items in treeview or to delete all items in treeview, it works fine. But if I do this to get text of the item, the SendMessage returns false.
Can anybody help, please?