HexEdit/Explorer.cpp
HRESULT CHistoryShellList::EnumObjects(LPSHELLFOLDER pParentFolder, LPITEMIDLIST pidlParent)
{
	ASSERT_VALID(this);

	LPENUMIDLIST pEnum;
	HRESULT hRes = pParentFolder->EnumObjects(NULL, m_nTypes, &pEnum);

	if (SUCCEEDED(hRes))
	{
		LPITEMIDLIST pidlTemp;
		DWORD dwFetched = 1;
		LPAFX_SHELLITEMINFO pItem;

		//enumerate the item's PIDLs
		while (pEnum->Next(1, &pidlTemp, &dwFetched) == S_OK && dwFetched)
		{
			SHFILEINFO	sfi;
			sfi.dwAttributes = SFGAO_FOLDER;
			VERIFY(SHGetFileInfo((LPCTSTR)pidlTemp, 0, &sfi, sizeof(sfi), SHGFI_PIDL | SHGFI_DISPLAYNAME | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED));
			if ((sfi.dwAttributes & SFGAO_FOLDER) == 0 && !PathMatchSpec(sfi.szDisplayName, m_filter))
			{
				dwFetched = 0;
				continue;       // skip this file as it does not match the current filter
			}

			LVITEM lvItem;
			ZeroMemory(&lvItem, sizeof(lvItem));

			//fill in the TV_ITEM structure for this item
			lvItem.mask = LVIF_PARAM | LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;

			//AddRef the parent folder so it's pointer stays valid
			pParentFolder->AddRef();

			//put the private information in the lParam
			pItem = (LPAFX_SHELLITEMINFO)GlobalAlloc(GPTR, sizeof(AFX_SHELLITEMINFO));

			pItem->pidlRel = pidlTemp;
			pItem->pidlFQ = theApp.GetShellManager()->ConcatenateItem(pidlParent, pidlTemp);

			pItem->pParentFolder = pParentFolder;
			lvItem.lParam = (LPARAM)pItem;

			lvItem.pszText = _T("");
			lvItem.iImage = OnGetItemIcon(GetItemCount(), pItem);

			//determine if the item is shared
			DWORD dwAttr = SFGAO_DISPLAYATTRMASK;
			pParentFolder->GetAttributesOf(1, (LPCITEMIDLIST*)&pidlTemp, &dwAttr);

			if (dwAttr & SFGAO_SHARE)
			{
				lvItem.mask |= LVIF_STATE;
				lvItem.stateMask |= LVIS_OVERLAYMASK;
				lvItem.state |= INDEXTOOVERLAYMASK(1); //1 is the index for the shared overlay image
			}

			if (dwAttr & SFGAO_GHOSTED)
			{
				lvItem.mask |= LVIF_STATE;
				lvItem.stateMask |= LVIS_CUT;
				lvItem.state |= LVIS_CUT;
			}

			int iItem = InsertItem(&lvItem);
			if (iItem >= 0)
			{
				// Set columns:
				const int nColumns = m_wndHeader.GetItemCount();
				for (int iColumn = 0; iColumn < nColumns; iColumn++)
				{
					SetItemText(iItem, iColumn, OnGetItemText(iItem, iColumn, pItem));
				}
			}

			dwFetched = 0;
		}

		pEnum->Release();
	}

	return hRes;
}
// This is very similar the base class version CMFCShellListCtrl::EnumObjects() but I had
// to duplicate the code in order to do filtering on the file name.

This is very similar the base class version CMFCShellListCtrl::EnumObjects() but I had
to duplicate the code in order to do filtering on the file name.
This is very similar the base class version CMFCShellListCtrl :: EnumObjects () but I had to duplicate the code in order to do filtering on the file name .
HRESULT CHistoryShellList::EnumObjects(LPSHELLFOLDER pParentFolder, LPITEMIDLIST pidlParent)
{
	ASSERT_VALID(this);
	LPENUMIDLIST pEnum;
	HRESULT hRes = pParentFolder->EnumObjects(NULL, m_nTypes, &pEnum);
	if (SUCCEEDED(hRes))
	{
		LPITEMIDLIST pidlTemp;
		DWORD dwFetched = 1;
		LPAFX_SHELLITEMINFO pItem;
		while (pEnum->Next(1, &pidlTemp, &dwFetched) == S_OK && dwFetched)
		{
			SHFILEINFO	sfi;
			sfi.dwAttributes = SFGAO_FOLDER;
			VERIFY(SHGetFileInfo((LPCTSTR)pidlTemp, 0, &sfi, sizeof(sfi), SHGFI_PIDL | SHGFI_DISPLAYNAME | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED));
			if ((sfi.dwAttributes & SFGAO_FOLDER) == 0 && !PathMatchSpec(sfi.szDisplayName, m_filter))
			{
				dwFetched = 0;
				continue;       
			}
			LVITEM lvItem;
			ZeroMemory(&lvItem, sizeof(lvItem));
			lvItem.mask = LVIF_PARAM | LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
			pParentFolder->AddRef();
			pItem = (LPAFX_SHELLITEMINFO)GlobalAlloc(GPTR, sizeof(AFX_SHELLITEMINFO));
			pItem->pidlRel = pidlTemp;
			pItem->pidlFQ = theApp.GetShellManager()->ConcatenateItem(pidlParent, pidlTemp);
			pItem->pParentFolder = pParentFolder;
			lvItem.lParam = (LPARAM)pItem;
			lvItem.pszText = _T("");
			lvItem.iImage = OnGetItemIcon(GetItemCount(), pItem);
			DWORD dwAttr = SFGAO_DISPLAYATTRMASK;
			pParentFolder->GetAttributesOf(1, (LPCITEMIDLIST*)&pidlTemp, &dwAttr);
			if (dwAttr & SFGAO_SHARE)
			{
				lvItem.mask |= LVIF_STATE;
				lvItem.stateMask |= LVIS_OVERLAYMASK;
				lvItem.state |= INDEXTOOVERLAYMASK(1); 
			}
			if (dwAttr & SFGAO_GHOSTED)
			{
				lvItem.mask |= LVIF_STATE;
				lvItem.stateMask |= LVIS_CUT;
				lvItem.state |= LVIS_CUT;
			}
			int iItem = InsertItem(&lvItem);
			if (iItem >= 0)
			{
				const int nColumns = m_wndHeader.GetItemCount();
				for (int iColumn = 0; iColumn < nColumns; iColumn++)
				{
					SetItemText(iItem, iColumn, OnGetItemText(iItem, iColumn, pItem));
				}
			}
			dwFetched = 0;
		}
		pEnum->Release();
	}
	return hRes;
}
HRESULT CHistoryShellList :: EnumObjects ( LPSHELLFOLDER pParentFolder , LPITEMIDLIST pidlParent ) { ASSERT_VALID ( this ) ; LPENUMIDLIST pEnum ; HRESULT hRes = pParentFolder -> EnumObjects ( NULL , m_nTypes , & pEnum ) ; if ( SUCCEEDED ( hRes ) ) { LPITEMIDLIST pidlTemp ; DWORD dwFetched = 1 ; LPAFX_SHELLITEMINFO pItem ; while ( pEnum -> Next ( 1 , & pidlTemp , & dwFetched ) == S_OK && dwFetched ) { SHFILEINFO sfi ; sfi . dwAttributes = SFGAO_FOLDER ; VERIFY ( SHGetFileInfo ( ( LPCTSTR ) pidlTemp , 0 , & sfi , sizeof ( sfi ) , SHGFI_PIDL | SHGFI_DISPLAYNAME | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED ) ) ; if ( ( sfi . dwAttributes & SFGAO_FOLDER ) == 0 && ! PathMatchSpec ( sfi . szDisplayName , m_filter ) ) { dwFetched = 0 ; continue ; } LVITEM lvItem ; ZeroMemory ( & lvItem , sizeof ( lvItem ) ) ; lvItem . mask = LVIF_PARAM | LVIF_TEXT | LVIF_IMAGE | LVIF_STATE ; pParentFolder -> AddRef ( ) ; pItem = ( LPAFX_SHELLITEMINFO ) GlobalAlloc ( GPTR , sizeof ( AFX_SHELLITEMINFO ) ) ; pItem -> pidlRel = pidlTemp ; pItem -> pidlFQ = theApp . GetShellManager ( ) -> ConcatenateItem ( pidlParent , pidlTemp ) ; pItem -> pParentFolder = pParentFolder ; lvItem . lParam = ( LPARAM ) pItem ; lvItem . pszText = _T ( " " ) ; lvItem . iImage = OnGetItemIcon ( GetItemCount ( ) , pItem ) ; DWORD dwAttr = SFGAO_DISPLAYATTRMASK ; pParentFolder -> GetAttributesOf ( 1 , ( LPCITEMIDLIST * ) & pidlTemp , & dwAttr ) ; if ( dwAttr & SFGAO_SHARE ) { lvItem . mask |= LVIF_STATE ; lvItem . stateMask |= LVIS_OVERLAYMASK ; lvItem . state |= INDEXTOOVERLAYMASK ( 1 ) ; } if ( dwAttr & SFGAO_GHOSTED ) { lvItem . mask |= LVIF_STATE ; lvItem . stateMask |= LVIS_CUT ; lvItem . state |= LVIS_CUT ; } int iItem = InsertItem ( & lvItem ) ; if ( iItem >= 0 ) { const int nColumns = m_wndHeader . GetItemCount ( ) ; for ( int iColumn = 0 ; iColumn < nColumns ; iColumn ++ ) { SetItemText ( iItem , iColumn , OnGetItemText ( iItem , iColumn , pItem ) ) ; } } dwFetched = 0 ; } pEnum -> Release ( ) ; } return hRes ; }
This is very similar the base class version CMFCShellListCtrl::EnumObjects() but I had
to duplicate the code in order to do filtering on the file name.
This is very similar the base class version CMFCShellListCtrl :: EnumObjects () but I had to duplicate the code in order to do filtering on the file name .
//enumerate the item's PIDLs
 // skip this file as it does not match the current filter
 //fill in the TV_ITEM structure for this item
 //AddRef the parent folder so it's pointer stays valid
 //put the private information in the lParam
 //determine if the item is shared
 //1 is the index for the shared overlay image
 // Set columns:
