I am utilizing a virtual lit control and that i obtain the data from the map. My issue is after i run the code, it shows their email list ok, however when a button cursor moves onto their email list control or after i attempt to scroll lower, it provides a Debug Assertion failure saying map/set iterator isn't dereferencable. My GetDispInfo() technique is the following:

void CListCtrlTestDlg::GetDispInfo(NMHDR* pNMHDR, LRESULT* pResult) 
{
   LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
   LV_ITEM* pItem = &(pDispInfo)->item;

   map<int, Error_Struct>::iterator it  = Error_Map.find((pItem->iItem) + 1);
   int iErrCode = (*it).second.i_ErrorCode;
   CString cError = (*it).second.c_Error;


    switch(pItem->iSubItem)
    {
    case 0:
        sprintf_s(pItem->pszText, 10, "[ %d ]", iErrCode);
        break;
    case 1:
        sprintf_s(pItem->pszText, 100, "%s", cError);
        break;
    }


*pResult = 0;

And if once the mouse pointer is on the top from the list control, again this program crashes saying access breach in the line demonstrated below in output.c file:

#else  /* _UNICODE */
   if (_putc_nolock(ch, f) == EOF)

Has anybody got exactly the same experience? What shall we be held doing wrong here and just how can one fix this issue?

Thanks!

To begin with, how are you aware that the miracle constants 10 and 100, that you are passing to sprintf_s are really the right quantity of space in pItem->pszText? You need to use pItem->cchText.

Second, you need to most likely make sure that the iterator came back from std::map::find applies.

The particular problem was which i was trying copy data to some non-buffer person in LV_ITEM structure. I had been attempting to copy data to some mere pointer, which was the issue. Things I must have really done ended up being to assign something to that particular pointer without copying data.

p = o_RBTree.FindByPosition((pItem->iItem) + 1);

char zKey[10];
zKey[0] = '\0';
sprintf_s(zKey, 10, "%d", p.first);

char zVal[100];
zVal[0] = '\0';
sprintf_s(zVal, 100, "%d", p.second);

if (pItem->mask && LVIF_TEXT) 
{
    switch(pItem->iSubItem)
    {
    case 0:
        pItem->pszText = zKey;
        break;
    case 1:
        pItem->pszText = zVal;
        break;
    }
}

This works perfectly! Just help.