ListView_GetItemText crashes
ListView_GetItemText crashes
我在windows 10机器中使用Visual Studio 2013,并编译64位win 32应用程序
我已经填充了如下列表控件:
// got the handle of the list control
HWND m_list = GetDlgItem (hwnddialog, IDC_LIST );
LVITEM x;
//Inserted row items
x.mask = LVIF_TEXT; x.iItem = 0; x.pszText = L"text"; x.state = 0;
x.stateMask = 0, x.iImage =0; x.lParam = 0; x.iSubItem = 0;
ListView_InsertItem( m_list, &x);
// Added column texts ...
ListView_SetItemText(m_list,0,1,"text details");
// etc... The list view shows fine.
//-------------------------Now I am trying to read the text from listview ------
wchar_t tptr[512];
ListView_GetItemText(m_list , 0,0, tptr, 5);
无论我在上面为项目和子项目输入什么值,以及我提供的tptr大小,(即使我将其设为本地或全局变量)程序在执行上面的行后崩溃:
sstwinpe64.exe中0x00007FFFC2CAA9AA(comctl32.dll)处未处理的异常:0xC000041D:在用户回调期间遇到未处理的例外
有必要在Win32中进行开发,因为现在只允许Win32程序在WinPE中运行。我的程序出了什么问题?提前感谢,Basudeb
我不知道你的项目结构,但你似乎混合了ANSI、Unicode和wchar:
x.pszText = L"text";
ListView_SetItemText(m_list,0,1,"text details");
wchar_t tptr[512];
我有一个奇怪的问题解决方案。它打败了我,但它是其中一个谜。仔细查看实际(而非伪造)代码:
wchar_t dsk[3200];
ListView_GetItemText(m_list,i,0,dsk,32); // Crashes as reported.
但我现在修改如下:编写了一个函数:
BOOL GetItemText(HWND hlist,int nitem, int nsubitem, wchar_t * txt, int ln)
{
ListView_GetItemText(hlist,nitem,nsubitem,txt,ln);
return TRUE;
}
并将我最初的呼叫修改为:GetItemText(m_list,i,0,dsk,32);
瞧!它工作并且不会崩溃。
有人能看穿这个谜题吗?我的问题解决了,我要走了。但这个谜会像一块沉重的石头一样在我编码的坑坑洼洼的道路上叮当作响。
相关文章:
- JNI getObjectClass crashes VM
- dll + boost + VS2015 + WinXP == crashes
- Cocos2d Firebase Admob crashes
- Directx11 - DeviceContext::ClearRenderTargetView crashes
- OpenCV Harris Corner Detection crashes
- 如何在CTreeCtrl中获取所选项目的文件类型?文件扩展名可能被隐藏,因此 GetItemText 没有帮助
- Qt Program Crashes aftes QTextEdit 通过 QTextCursor 进行修改
- OpenGL glBufferStorage crashes
- vector.push_back() crashes
- wxToggleButton::GetValue() crashes
- ListView_GetItemText crashes
- WaitForSingleObject crashes
- SGS4 android 4.4.2 - OGL ES2 crashes
- QAbstractListModel crashes
- RegisterClassEx crashes - C++
- ShellExecute crashes
- OpenCL: cl::getDevices crashes
- _strset_s crashes
- BHO HtmlEventObject crashes
- vswprintf crashes