Click to See Complete Forum and Search --> : TVM_GETITEMRECT & TreeView


Nif
March 2nd, 2006, 08:55 AM
I can't get TVM_GETITEMRECT to work while trying to retrieve
the rect occupied by some item in the TreeView when it's owned
by the window belonging to another thread. It just returns
incorrect data in rect and that's it. I've been trying to handle the
issue by allocating memory in another process' space, but it won't help.
I'm completely lost and have no idea how this is supposed to be done in order
to retrieve correct rect coordinates for treeview items. Please advise.

kirants
March 2nd, 2006, 04:34 PM
Slightly confusing, you say, you are trying to get item rect on a tree view created in another thread, but is it in the same process or someother. I believe it is someother process per your later statements.

However, even allocating space in other space won't work, since the rect you are passing and then analysing after send message is still in the callers address space. How about using shared data rather and hook into the other process to do all this ?

See example here:
Three Ways To Inject Your Code Into Another Process (http://www.codeguru.com/cpp/w-p/system/processesmodules/article.php/c5767/)

MikeAThon
March 2nd, 2006, 04:39 PM
Are you using SendMessage directly, as in the following code (taken from http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/treeview/messages/tvm_getitemrect.asp )
RECT rc;
*(HTREEITEM*)&rc = hTreeItem;
SendMessage(hwndTreeView, TVM_GETITEMRECT, FALSE, (LPARAM)&rc);
If not, then show us your code, since the above code should work even inter-thread, so long as the HTREEITEM is valid.

Mike