Link to home
Start Free TrialLog in
Avatar of ViperX
ViperX

asked on

getting text from a listview control

How do I get the text in a listview control from another program. its classname is SysListView32 so assume its a listview control.
Thank you.
Avatar of MikeP090797
MikeP090797

If you have the listview's handle, you can use SendMessage with LVM_ messages to get the items. To get the handle, you can use FindWindow and FindWindowEx. the LVM_GETITEMCOUNT message will give you the number of items, the LVM_GETITEM message will return information about item, incuding text.
You can get some more info at:
http://www.mvps.org/vbnet/code/_acc/ndxcomctl.htm
Avatar of ViperX

ASKER

Basicly you have told me the correct comamnd to do what i want to do. but it doesn't work. heres what i did.
listview% = my handle which does equal true! syslistview32
SendNow% = SendMessageByNum(listview%, LVM_GETITEMCOUNT, &HD, 0)

then i msgbox sendnow%
my msgbox was a value of 0 err help!
I think here is the part that you are missing.
Now you have to find a way to split the points.

Dim lvi as LVITEM

itemcount = SendMessage(listview%, LVM_GETITEMCOUNT, 0, byval 0)
for i = 1 to itemcount
    itemcount = SendMessageAny(listview%, LVM_GETITEM, i, lvi)
next
Avatar of ViperX

ASKER

I get problems like LVITEM  isn't defined and, SendMessageAny isn't defined. I think I need some LVM commands to go into my module file. If you have the ones I need I'd be happy if you tell me them.
Thanks
SendMessageAny is just a regular SendMessage

Public Type LV_ITEM
    mask as long
    iItem as long
    iSubItem as long
    state as long
    stateMask as long
    pszText as string
    cchTextMax as long
    iImage as long
    lParam as long
End Type

Avatar of ViperX

ASKER

hmmm  i can't get this working. i dont feel like bothering you anymore. but i apreciate the help. thank you.
Is the other program made in VB? I've seen some problems with VB made apps and common controls. Also, use the Long type on the list handle, not integer (& instead of %)
Avatar of ViperX

ASKER

nah its in c++
I thought at least getting the count would be easy to do :)
well I may end up giving up on this project i want to do.
But thats ok, I hope in the future my better exparience will help me.

If you still want to I have some sample code to do this...
Avatar of ViperX

ASKER

Ya I really want to do this badly.
Look, I really am not all that great with VB. I try to learn off of source code. Which I do. Please just assum I have the handle of the syslistview32 which i do.. I need all the code that will define the lvm commands so that I can get the count, and get the item...
so when I msgbox count, it will tell me the count.
When I msgbox the first item in the list view, it will tell me...
just show me how to disply the first item please... that would be number 0 i think... I can make the counters .. make it simple.. please.  thank you
ASKER CERTIFIED SOLUTION
Avatar of Mirkwood
Mirkwood

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 ViperX

ASKER

well thanks... to bad vb6 rejects it...
Avatar of ViperX

ASKER

Ok, I'v done some searching and someone told me that I have to hook this window I want and recieve the in comming windows messages and add each message into a text box. I really dont know how to do this and if it wouldn't be to much trouble I would be thankful if you could tell me a place that will show me what I need to know.  
b = SendMessageAny(m_lvHwnd, LVM_GETITEMTEXT, i, lvi)
Not Work