AFX_INLINE int CGridListCtrlGroups::SetGroupInfo(int iGroupId, PLVGROUP pgrp) { ASSERT(::IsWindow(m_hWnd)); return (int)ListView_SetGroupInfo(m_hWnd, iGroupId, pgrp); }
/* * Checks if a group with specified id is already * in the listview. If not, the group is inserted * into its sorted position with the specified * header text. */ int CShellBrowser::CheckGroup(TCHAR *szGroupHeader, PFNLVGROUPCOMPARE pfnGroupCompare) { LVINSERTGROUPSORTED lvigs; std::list<TypeGroup_t>::iterator itr; TypeGroup_t TypeGroup; WCHAR wszHeader[512]; BOOL bFoundGroup = FALSE; int iGroupId = -1; /* Check to see if the group has already been inserted... */ for(itr = m_GroupList.begin();itr != m_GroupList.end();itr++) { if(lstrcmpi(szGroupHeader,itr->szHeader) == 0) { LVGROUP lvGroup; bFoundGroup = TRUE; iGroupId = itr->iGroupId; itr->nItems++; if(m_dwMajorVersion >= WINDOWS_VISTA_SEVEN_MAJORVERSION) { StringCchPrintf(wszHeader,SIZEOF_ARRAY(wszHeader), _T("%s (%d)"),szGroupHeader,itr->nItems); lvGroup.cbSize = sizeof(LVGROUP); lvGroup.mask = LVGF_HEADER; lvGroup.pszHeader = wszHeader; ListView_SetGroupInfo(m_hListView,iGroupId,&lvGroup); } break; } } if(!bFoundGroup) { iGroupId = m_iGroupId++; StringCchCopy(TypeGroup.szHeader,SIZEOF_ARRAY(TypeGroup.szHeader), szGroupHeader); TypeGroup.iGroupId = iGroupId; TypeGroup.nItems = 1; m_GroupList.push_back(TypeGroup); if(m_dwMajorVersion >= WINDOWS_VISTA_SEVEN_MAJORVERSION) { StringCchPrintf(wszHeader,SIZEOF_ARRAY(wszHeader), _T("%s (%d)"),szGroupHeader,TypeGroup.nItems); } else if(m_dwMajorVersion >= WINDOWS_XP_MAJORVERSION) { StringCchPrintf(wszHeader,SIZEOF_ARRAY(wszHeader), _T("%s"),szGroupHeader); } /* The group is not in the listview, so insert it in. */ lvigs.lvGroup.cbSize = sizeof(LVGROUP); lvigs.lvGroup.mask = LVGF_HEADER|LVGF_GROUPID; lvigs.lvGroup.pszHeader = wszHeader; lvigs.lvGroup.iGroupId = iGroupId; lvigs.lvGroup.stateMask = 0; OSVERSIONINFO vi; vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if(GetVersionEx(&vi) != 0) { /* LVGS_COLLAPSIBLE is only valid on Windows Vista and later. */ if(vi.dwMajorVersion > WINDOWS_XP_MAJORVERSION) { lvigs.lvGroup.mask |= LVGF_STATE; lvigs.lvGroup.state = LVGS_COLLAPSIBLE; } } lvigs.pfnGroupCompare = (PFNLVGROUPCOMPARE)pfnGroupCompare; lvigs.pvData = NULL; ListView_InsertGroupSorted(m_hListView,&lvigs); } return iGroupId; }