Link to home
Start Free TrialLog in
Avatar of Muerty
Muerty

asked on

SysTreeView32 item captions

Let me see if I can fiind a simple way of explaining what I need to do ....

I have the need to read the captions from a SysTreeView32 control in another application so I can differentiate a specific item to select based upon it's name since the position of the item may move from time to time.

Let me be more specific. I have several folders in Outlook Express that has messages coming in from various email addresses. What I need to do is be able to identify a specific email folder, set it current, and then enumerate the messages to extract data from the messages.

I am able to identify the SysTreeView32 control in the Folders window, and I am able to operate on the control using the SendMessage API, but I am currently not able to extract the caption from the items in the control.

I have tried sending a GetWindowText call to the individual items in the TreeView, but it does not return the caption to the hItem returned by the GetChild API.

TIA
ASKER CERTIFIED SOLUTION
Avatar of zzzzzooc
zzzzzooc

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zzzzzooc
zzzzzooc

Would've saved me time if you posted sooner! :P The other PAQ of yours helped me with something else so thanks... the empty strings on Win2k/XP were because of the buffer string having a static-length.
I'm too far from home now (about 2500 km) so I can not react so quickly :)
Avatar of Muerty

ASKER

Ok forgive me for being a bit ignorant on this matter, but where in the above code do you ever set the value of strLvItem ......
I simply placed  a msgbox to display the value returned from TreeViewGetText and it returns a zero length string.... I also decided to embed the msgbox into the functio, it also returned a zero length string.

I feel as though I am missing something....
>>but where in the above code do you ever set the value of strLvItem
I referred to strLvItem by it's pointer (string pointer, since the variable's pointer would just point to another pointer in memory (BSTR)). lngVarPtr1 is the pointer to strLvItem and lngMemVar1 is the pointer for the allocated memory which the SendMessage() line fills (when passing it the LVITEM UDT). After lngMemVar1 was "filled", the ReadProcessMemory() line copied the string to lngMemVar1 (which is basically "setting the value"). You should refer to Ark's links (and his links from there and so forth) since he's detailed a lot of it.

>>and it returns a zero length string
I mentioned hard-coding the window-handle for the ListView control so if you didn't change it, that's probably the cause.

Change to something such as:
Me.Print TreeViewGetText(ListView1.hWnd, 0, intLoop)
Avatar of Muerty

ASKER

I hard coded the handle of the SysTreeView32 directly from Spy++, but I actually use in my programming the EnumChildWindows API ...

I am still unable to get the info from there... I will see if there is another route that will solve the issue ...

I read the issues with XP/2000 and I am using XP... is there another issue that I am missing?
It worked for me on Win2k and same method for a friend on XP.

Set up break-points to see where the procedure leads. Replace "Call" with "Debug.Print". The WriteProcessMemory(), ReadProcessMemory(), and SendMessage() functions should return non-zero. If not, they failed and you can try getting the last DLL error.