I am using Visual Studio 2013 in windows 10 machines and compiling 64 bit win 32 applications
I have populated a list control as below:
// 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);
Whatever value I enter above for item, and subitem and whatever I provide as the size of tptr, ( even if I make it a local or global variable) the programcrashes after executing the above line:
Unhandled exception at 0x00007FFFC2CAA9AA (comctl32.dll) in sstwinpe64.exe: 0xC000041D: An unhandled exception was encountered during a user callback.
It is necessary to develop this in Win32 as only Win32 programs are permitted to run in WinPE now. What is wrong in my program? Thanking in advance, Basudeb
I don't know your project structure, but it seems that you have some mixture of ANSI, Unicode and wchar:
x.pszText = L"text";
ListView_SetItemText(m_list,0,1,"text details");
wchar_t tptr[512];
I have got a weird solution to the problem. It beats me, but it is one of those mysteries. Look at the actual (not fake) code carefully:
wchar_t dsk[3200];
ListView_GetItemText(m_list,i,0,dsk,32); // Crashes as reported.
But I have modified it now as below: written a function:
BOOL GetItemText(HWND hlist,int nitem, int nsubitem, wchar_t * txt, int ln)
{
ListView_GetItemText(hlist,nitem,nsubitem,txt,ln);
return TRUE;
}
And modified my original call to : GetItemText(m_list,i,0,dsk,32);
And lo! It works and does not crash.
Anyone can see thru this puzzle? My problem is solved and I will go away. But the mystery will keep clanging like a heavy stone on the pothole-filled path of my coding .
User contributions licensed under CC BY-SA 3.0