Problem with Virtual List Control in the Emulator of Pocket PC
-
Dear all, I had tried to use List Control in Virtual List mode using eVC 3.0. But I met a problem that I cannot solve. The problem is when I click on the list item of the List (my program run in the Pocket PC Emulator), I got an error message "Assertion failed. TestProg: File winctrl2.cpp, Line 479" But with that program, I run it on a Pocket PC, nothing happen when I click on List item. Please tell me what I did wrong. Thank you very much in advance.
-
Dear all, I had tried to use List Control in Virtual List mode using eVC 3.0. But I met a problem that I cannot solve. The problem is when I click on the list item of the List (my program run in the Pocket PC Emulator), I got an error message "Assertion failed. TestProg: File winctrl2.cpp, Line 479" But with that program, I run it on a Pocket PC, nothing happen when I click on List item. Please tell me what I did wrong. Thank you very much in advance.
Bui Huy Kien wrote: Please tell me what I did wrong. You forgot to set the
LVS_OWNERDATA
window style. Regards, João Paulo Figueira Embedded MVP -
Bui Huy Kien wrote: Please tell me what I did wrong. You forgot to set the
LVS_OWNERDATA
window style. Regards, João Paulo Figueira Embedded MVPNo, I do insert the LVS_OWNERDATA style when creating the List Control. Here is the code:
if(m_wndList.Create(WS_CHILD|WS_VISIBLE|LVS_OWNERDATA|LVS_SINGLESEL|LVS_REPORT|LVS_NOCOLUMNHEADER|LVS_NOSORTHEADER,CRect(0,0,243,224), this, MAIN_LIST)) { // Set List Control style to Full Row Select DWORD dwStyle = m_wndList.GetExtendedStyle(); dwStyle |= LVS_EX_FULLROWSELECT; m_wndList.SetExtendedStyle(dwStyle); } void CChildView::OnGetdispinfoList(NMHDR* pNMHDR, LRESULT* pResult) { LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR; // TODO: Add your control notification handler code here LV_ITEM* pItem= &(pDispInfo)->item; int iItemIndx = pItem->iItem; switch (g_nWorkingMode) { case 0: case 4: { CTimeRegItem *pListItem; pListItem = (CTimeRegItem*) m_arrayElements[iItemIndx]; if (pItem->mask & LVIF_TEXT) //valid text buffer? { switch (pItem->iSubItem) { case 0: //Fill in main text lstrcpy(pItem->pszText, pListItem->m_strID); break; case 1: //Fill in subitem 1 lstrcpy(pItem->pszText, pListItem->m_strDate); break; case 2: //Fill in subitem 2 lstrcpy(pItem->pszText, pListItem->m_strDescription); break; case 3: //Fill in subitem 3 lstrcpy(pItem->pszText, pListItem->m_strDuration); break; } } else if (pItem->mask & LVIF_IMAGE) { pItem->iImage = pListItem->m_nImage; } } break; case 1: { COtherListItem *pListItem; pListItem = (COtherListItem*) m_arrayElements[iItemIndx]; if (pItem->mask & LVIF_TEXT) //valid text buffer? { switch (pItem->iSubItem) { case 0: //Fill in main text lstrcpy(pItem->pszText, pListItem->m_strID); break; case 1: //Fill in subitem 1 lstrcpy(pItem->pszText, pListItem->m_strType); break; case 2: //Fill in subitem 2 lstrcpy(pItem->pszText, pListItem->m_strName); break; } } } break; case 2: case 3: { COtherListItem *pListItem; pListItem = (COtherListItem*) m_arrayElements[iItemIndx]; if (pItem->mask & LVIF_TEXT) //valid text buffer? { switch (pItem->iSubItem) { case 0: //Fill in main text lstrcpy(pItem->pszText, pListItem->m_strID); break; case 1: //Fill in subitem 1 lstrcpy(pItem->pszText, pListItem->m_strName); break; } } } break; } break; } *pRe
-
No, I do insert the LVS_OWNERDATA style when creating the List Control. Here is the code:
if(m_wndList.Create(WS_CHILD|WS_VISIBLE|LVS_OWNERDATA|LVS_SINGLESEL|LVS_REPORT|LVS_NOCOLUMNHEADER|LVS_NOSORTHEADER,CRect(0,0,243,224), this, MAIN_LIST)) { // Set List Control style to Full Row Select DWORD dwStyle = m_wndList.GetExtendedStyle(); dwStyle |= LVS_EX_FULLROWSELECT; m_wndList.SetExtendedStyle(dwStyle); } void CChildView::OnGetdispinfoList(NMHDR* pNMHDR, LRESULT* pResult) { LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR; // TODO: Add your control notification handler code here LV_ITEM* pItem= &(pDispInfo)->item; int iItemIndx = pItem->iItem; switch (g_nWorkingMode) { case 0: case 4: { CTimeRegItem *pListItem; pListItem = (CTimeRegItem*) m_arrayElements[iItemIndx]; if (pItem->mask & LVIF_TEXT) //valid text buffer? { switch (pItem->iSubItem) { case 0: //Fill in main text lstrcpy(pItem->pszText, pListItem->m_strID); break; case 1: //Fill in subitem 1 lstrcpy(pItem->pszText, pListItem->m_strDate); break; case 2: //Fill in subitem 2 lstrcpy(pItem->pszText, pListItem->m_strDescription); break; case 3: //Fill in subitem 3 lstrcpy(pItem->pszText, pListItem->m_strDuration); break; } } else if (pItem->mask & LVIF_IMAGE) { pItem->iImage = pListItem->m_nImage; } } break; case 1: { COtherListItem *pListItem; pListItem = (COtherListItem*) m_arrayElements[iItemIndx]; if (pItem->mask & LVIF_TEXT) //valid text buffer? { switch (pItem->iSubItem) { case 0: //Fill in main text lstrcpy(pItem->pszText, pListItem->m_strID); break; case 1: //Fill in subitem 1 lstrcpy(pItem->pszText, pListItem->m_strType); break; case 2: //Fill in subitem 2 lstrcpy(pItem->pszText, pListItem->m_strName); break; } } } break; case 2: case 3: { COtherListItem *pListItem; pListItem = (COtherListItem*) m_arrayElements[iItemIndx]; if (pItem->mask & LVIF_TEXT) //valid text buffer? { switch (pItem->iSubItem) { case 0: //Fill in main text lstrcpy(pItem->pszText, pListItem->m_strID); break; case 1: //Fill in subitem 1 lstrcpy(pItem->pszText, pListItem->m_strName); break; } } } break; } break; } *pRe
:doh: Sorry! I "shot from the hip" and didn't realise what the assert is all about. The code is asserting on
CListCtrl::SetItemText
. This method cannot work if you have theLVS_OWNERDATA
style set. To change the data on aLVS_OWNERDATA
list view, you must change the underlying data structure and invalidate the row. If you are adding new rows, you must reflect the new row (item) count. Regards, João Paulo Figueira Embedded MVP -
:doh: Sorry! I "shot from the hip" and didn't realise what the assert is all about. The code is asserting on
CListCtrl::SetItemText
. This method cannot work if you have theLVS_OWNERDATA
style set. To change the data on aLVS_OWNERDATA
list view, you must change the underlying data structure and invalidate the row. If you are adding new rows, you must reflect the new row (item) count. Regards, João Paulo Figueira Embedded MVPThank you so much. You are very kind. Finally, I found that I had called the SetItem function in my code. Best regards, -Kien Bui