CListCtrl I_GROUPIDCALLBACK doesn't work on Windows XP?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have a ListView control in my simple which have one group, I want to set the items group id dynamic, but I never receive LVIF_GROUPID notify in LVN_GETDISPINFO. Its work properly in Win7, So how to fix this issue? below is the code
snap

<span style="white-space:pre m_ListCtrl.SetImageList(&m_ImgList, LVSIL_SMALL);
<span style="white-space:pre VERIFY(m_ListCtrl.EnableGroupView(TRUE) == 1);
<span style="white-space:pre CString wstrGroupName(_T("Running"));
<span style="white-space:pre LVGROUP lvg;
<span style="white-space:pre ZeroMemory(&lvg, sizeof(lvg));
<span style="white-space:pre lvg.cbSize = sizeof(lvg);
<span style="white-space:pre lvg.mask = LVGF_HEADER | LVGF_GROUPID | LVGF_ALIGN;
<span style="white-space:pre lvg.pszHeader = wstrGroupName.GetBuffer();
<span style="white-space:pre lvg.cchHeader = (int)wcslen(lvg.pszHeader);
<span style="white-space:pre lvg.iGroupId = 1;
<span style="white-space:pre lvg.uAlign = LVGA_HEADER_CENTER;
<span style="white-space:pre VERIFY(m_ListCtrl.InsertGroup(-1, &lvg) > -1);
<span style="white-space:pre
<span style="white-space:pre // Insert column(s) (only needed for report view)
<span style="white-space:pre m_ListCtrl.InsertColumn(0, _T("Item Name"), LVCFMT_LEFT, 26);
<span style="white-space:pre m_ListCtrl.InsertColumn(1, _T("Item Context"), LVCFMT_LEFT, 160);
<span style="white-space:pre // Insert items
<span style="white-space:pre for (int i=1; i<=20; i++)
<span style="white-space:pre {
<span style="white-space:pre // Set item group ID
<span style="white-space:pre LVITEM lvi;
<span style="white-space:pre ZeroMemory(&lvi, sizeof(lvi));
<span style="white-space:pre
<span style="white-space:pre lvi.mask = LVIF_GROUPID | LVIF_IMAGE ;
<span style="white-space:pre lvi.iImage = i % 2 == 0 ? I_IMAGENONE : 0;

<span style="white-space:pre lvi.iGroupId = I_GROUPIDCALLBACK;
<span style="white-space:pre lvi.iItem = i ;
<span style="white-space:pre int iItem = m_ListCtrl.InsertItem(&lvi);
<span style="white-space:pre
<span style="white-space:pre ZeroMemory(&lvi, sizeof(lvi));
<span style="white-space:pre CString strMsg;

<span style="white-space:pre if (i % 2 == 0)
<span style="white-space:pre {
<span style="white-space:pre strMsg.Format(_T("My Sub-Item(%d)"), i / 2);
<span style="white-space:pre lvi.mask = LVIF_IMAGE | LVIF_TEXT;
<span style="white-space:pre }
<span style="white-space:pre else
<span style="white-space:pre {
<span style="white-space:pre lvi.mask = LVIF_TEXT ;
<span style="white-space:pre strMsg.Format(_T("My Item(%d)"), i / 2 + 1);
<span style="white-space:pre }
<span style="white-space:pre lvi.iImage = 1;
<span style="white-space:pre lvi.pszText = strMsg.GetBuffer();
<span style="white-space:pre lvi.cchTextMax = strMsg.GetLength();
<span style="white-space:pre lvi.iItem = iItem;
<span style="white-space:pre lvi.iSubItem = 1;
<span style="white-space:pre ASSERT(m_ListCtrl.SetItem(&lvi));
<span style="white-space:pre }

void CLstDlg::OnLvnGetdispinfoJobs(NMHDR *pNMHDR, LRESULT *pResult)
{
<span style="white-space:pre NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
<span style="white-space:pre if (pDispInfo->item.mask & LVIF_GROUPID)
<span style="white-space:pre {
<span style="white-space:pre //Never run here? strange, work OK on Win7
<span style="white-space:pre pDispInfo->item.iGroupId = 1;
<span style="white-space:pre }
<span style="white-space:pre *pResult = 0;
}
Thanks




View the full article
 
Back
Top