Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm fairly new with win32 programming, and have met my first roadblock with using the listview control. inserting and adding items is fine, but when i try to retrieve the item's text, i get the text BUT without the first two characters.... Im a bit lost here and would really appreciate any help i can get.

Here's a snippet of the code i use to get the item text:

LVITEM lvi;
TCHAR szBuffer[256] = {0};
ZeroMemory(&lvi, sizeof(lvi));

lvi.mask = LVIF_TEXT;
lvi.iSubItem = 0;
lvi.pszText = szBuffer;
lvi.cchTextMax = 256;
lvi.iItem = 0;
SendMessage(hWndListView, LVM_GETITEM, 0, (LPARAM)&lvi);


Now, instead of getting "Hello", I get "llo" :confused: :confused: :confused:

Thanks
Posted

1 solution

Looks ok to me. Are you inspecting lvi.pszText or szBuffer afterwards?

MSDN states "Applications should not assume that the text will necessarily be placed in the specified buffer. The control may instead change the pszText member of the structure to point to the new text, rather than place it in the buffer."
 
Share this answer
 
Comments
ccscabang 8-Jun-10 8:26am    
Thanks!!!

I can't believe how stupid I was.... thanks thanks thanks....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900