Hi All,
I am trying to get a treenode's state image by sending TVM_GETITEM messgae
to the treeview.
I have set ...
TVITEM.mask = TVIF_STATE
TVITEM.stateMask = TVIS_STATEIMAGEMASK
TVITEM.hItem = <item whose state image i want ot know>
all other members of TVITEM are set to zero.
I am using SendMessage to send this message to TreeView. The sendmessage
call returns successfully, but TVITEM.state is always set to TVIS_SELECTED
(0x02). I am wondering that how come 2nd bit of TVITEM.state is set while i
have set TVITEM.stateMask = TVIS_STATEIMAGEMASK which means that only bit 12
to 15 must be set/reset.
I used SPY++ and verified that i am sending correct message to correct
treeview. SPY++ also shows taht all the members of TVITEM are set to the
values which i have set which i have set to before calling sendmessage. It
also shows that Treeview processed the message succeessfuly.
Using SPY++ only i observed that after processing the messgae, TVITEM.
stateMask is always set to TVIS_STATEIMAGEMASK.
Can someone please help me out in finding the root cause?
Other data which i feel can be useful is...
1. I tried setting TVITEM.stateMask = TVIS_STATEIMAGEMASK | TVIS_OVERLAYMASK
bur still TVITEM.state is set to TVIS_SELECTED.
2. I tried setting TVITEM.stateMask = TVIS_OVERLAYMASK bur still TVITEM.
state is set to TVIS_SELECTED.
3. The window class name of treeView is SysTreeView32.
4. I am working in managed world so i am using dllimport to send this
message. But i am sure it is not causing problem because i can see that
messages is sent correctly (using SPY++).
5. I am working on WindowsXP2.
Please respond as i am badly blocked on this issue.
Thanks,
Jaiprakash
Mattias Sjögren - 05 Oct 2005 16:19 GMT
>I am trying to get a treenode's state image by sending TVM_GETITEM messgae
>to the treeview.
Is this Treeview in your own application or another? The message
probably only works as expected in-proc.
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jaiprakash - 06 Oct 2005 05:16 GMT
Hi,
Treeview is in another application. The process X which is sending the
message is different from the process Y who owns the treeview. But i am
taking care of it by allocating memory in process Y (using VirtualAllocX())
for TVITEM structure.
I am following these steps...
1. VirtualAllocX in process x to allocate sizeof(TVITEM) in process Y. Lets
say it returned pVirtualMem.
2. Call WriteProcessMemory to write TVITEM in process Y memory at
pVirtualMem.
3. Call sendmessage and pass the pVirtualMem as pointer to TVITEM.
4. Once call succeeded, use ReadProcessMemory to read modified TVITEM at
pVirtualMem.
As i have said that i have crosschecked that what i am getting is exactly
what SPY++ is also showing, so i hardly doubt that above steps have anything
wrong with them.
Thanks.
Jaiprakash - 06 Oct 2005 13:45 GMT
Please note that my treeview has checkboxes. I want to verify
programatically that a particular checkbox is selected or not. I am
expecting that different indexes are returned for checked/unchecked check
box item.
Thanks.