使用LVM_GETITEM检索项目文本时,缺少前两个字符 [英] Missing first two characters when retrieving item text with LVM_GETITEM

查看:168
本文介绍了使用LVM_GETITEM检索项目文本时,缺少前两个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我对Win32编程还很陌生,并且使用listview控件遇到了我的第一个障碍.插入和添加项目很好,但是当我尝试检索项目的文本时,我得到的文本没有前两个字符....我在这里有点迷失了,我将非常感谢我能提供的任何帮助.

这是我用来获取商品文本的代码片段:

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);



现在,我没有得到"Hello",而是得到了"llo".:confused::confused::confused:

谢谢



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

Thanks

推荐答案

对我来说还不错.之后要检查lvi.pszText还是szBuffer?

MSDN指出:应用程序不应假定文本必须放置在指定的缓冲区中.控件可以改为将结构的pszText成员更改为指向新文本,而不是将其放置在缓冲区中."
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."


这篇关于使用LVM_GETITEM检索项目文本时,缺少前两个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆