void CTDCTaskListCtrl::RestoreSelection(const TDCSELECTIONCACHE& cache)
{
	if (cache.aSelTaskIDs.GetSize() == 0)
	{
		DeselectAll();
		return;
	}

	DWORD dwFocusedTaskID = cache.dwFocusedTaskID;
	ASSERT(dwFocusedTaskID);
	
	if (FindTaskItem(dwFocusedTaskID) == -1)
	{
		dwFocusedTaskID = 0;
		int nID = cache.aBreadcrumbs.GetSize();
		
		while (nID--)
		{
			dwFocusedTaskID = cache.aBreadcrumbs[nID];
			
			if (FindTaskItem(dwFocusedTaskID) != -1)
				break;
			else
				dwFocusedTaskID = 0;
		}
	}
	
	// add focused task if it isn't already
	CDWordArray aTaskIDs;
	aTaskIDs.Copy(cache.aSelTaskIDs);

	if (Misc::FindT(aTaskIDs, dwFocusedTaskID) == -1)
		aTaskIDs.Add(dwFocusedTaskID);

	SetSelectedTasks(aTaskIDs, dwFocusedTaskID);
	
	// restore pos
	if (cache.dwFirstVisibleTaskID)
		SetTopIndex(FindTaskItem(cache.dwFirstVisibleTaskID));
}
BOOL CTDCTaskListCtrl::SelectTasks(const CDWordArray& aTaskIDs, BOOL bTrue)
{
	ASSERT(aTaskIDs.GetSize());

	if (!aTaskIDs.GetSize())
		return FALSE;

	if (!bTrue)
	{
		SetSelectedTasks(aTaskIDs, aTaskIDs[0]);
	}
	else
	{
		CDWordArray aTrueTaskIDs;
		
		aTrueTaskIDs.Copy(aTrueTaskIDs);
		m_data.GetTrueTaskIDs(aTrueTaskIDs);
		
		SetSelectedTasks(aTrueTaskIDs, aTrueTaskIDs[0]);
	}

	return TRUE;
}