I’m trying to create Listview control with two column using bellow code.
LV_COLUMN lvc = {0};
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
lvc.fmt = LVCFMT_LEFT;
lvc.cx = 180;
lvc.pszText = _T("Title");
lvc.cchTextMax = _tcslen(lvc.pszText);
ListView_InsertColumn(hwndList, 0, &lvc);
lvc.pszText = _T("ApplicationName");
lvc.cchTextMax = _tcslen(lvc.pszText);
ListView_InsertColumn(hwndList, 1, &lvc);
to insert two colomns. This is successfully inserted.
Then i want to add 2 items in 1st row for Title & ApplicationName colomn respectively.
i’m using structure:
typedef struct{
TCHAR m_title[512];
TCHAR m_Application[512];
}APPLICATION_LIST;
and then trying to insert multiple items in a same row using:
APPLICATION_LIST *pAppList = new APPLICATION_LIST;
if(pAppList)
{
_tcscpy(pAppList->m_title,TEXT("My Mozilla"));
_tcscpy(pAppList->m_Application,TEXT("FireFox"));
}
LVITEM lvi = {0};
lvi.mask = LVIF_PARAM | LVIF_TEXT;
lvi.iItem = ListView_GetItemCount(hwndList);
lvi.pszText = LPSTR_TEXTCALLBACK ;
ListView_InsertItem(hwndList,&lvi);
But i’m not able to insert multiple items into same row using this ! where i gone wrong ? No item will be inserted while doing so !
Please help me to correct this code ? Then how can i insert multiple items into same row for the list view control.
You are specifying the
LVIF_PARAMflag, but you are not assigning thelvi.lParamfield. You need to add that. Then, to useLPSTR_TEXTCALLBACKcorrectly, the message procedure of the ListView’s parent window needs to handle theLVN_GETDISPINFOnotification. It will provide a pointer to aLVITEMstruct that specifies which list item and column it wants you to provide text for. You can use that item’slParamto access yourAPPLICATION_LISTpointer and copy the appropriate string into the item’spszTextbuffer.For example:
.
.