Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / October 2005

Tip: Looking for answers? Try searching our database.

TVITEM.state is set incorrectly for treenodes.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jaiprakash - 05 Oct 2005 15:19 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.