As David says, you should text for the LVIF_TEXT before using this buffer. This routine gets called for lots of different reasons. This article may be interesting to you:

Also, when setting the text be sure you don't exceed the buffer.


"Alamelu" <Alamelu@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:C8BE2CA6-58BE-40EC-B7FD-3AC6459F7295@xxxxxxxxxxxxxxxx
In the below code "pDispInfo->item.pszText" is holding some address and is
pointing to some junk value only in release mode, which gives me a uncaught
expection in that line. But in debug mode "pDispInfo->item.pszText" is NULL.

void ClassA::OnBeginEditList(NMHDR *pNMHDR, LRESULT *pResult,CListCtrl
NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
CString strData = pDispInfo->item.pszText ; //Gives uncaught expection

Can any body guess why would "pDispInfo->item.pszText" point to some address
and hold some junk value when we begin to edit List view control. But
logically "pDispInfo->item.pszText" should be NULL when we begin to edit the
control, isn't it? Why this strange behaviour happens only in release mode

Is there any flag, to check if "pDispInfo->item.pszText" holds any value and
accordingly retrieve?

Alamelu N