//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CMapCheckDlg::OnSelchangeErrors() 
{
	// change description to match error
	int iSel = m_Errors.GetCurSel();

	if(iSel == LB_ERR)
	{
		m_Fix.EnableWindow(FALSE);
		m_cFixAll.EnableWindow(FALSE);
		m_Go.EnableWindow(FALSE);
	}

	CString str;
	MapError *pError;
	pError = (MapError*) m_Errors.GetItemDataPtr(iSel);

	str.LoadString(ID_DESCRIPTIONS_START + pError->Type);
	m_Description.SetSel(0, -1);
	m_Description.ReplaceSel(str);

	m_Go.EnableWindow(pError->pObjects[0] != NULL);

	// set state of fix button
	m_Fix.EnableWindow(pError->Fix == NeedsFix);
	m_cFixAll.EnableWindow(pError->Fix != CantFix);

	// set text of fix button
	switch(pError->Fix)
	{
	case NeedsFix:
		m_Fix.SetWindowText("&Fix");
		break;
	case CantFix:
		m_Fix.SetWindowText("Can't fix");
		break;
	case Fixed:
		m_Fix.SetWindowText("(fixed)");
		break;
	}

	CMapDoc *pDoc = CMapDoc::GetActiveMapDoc();

	pDoc->Selection_SetMode(selectObjects);
	
	if (pError->pObjects[0])
	{
		pDoc->SelectObject(pError->pObjects[0], CMapDoc::scClear | CMapDoc::scSelect | CMapDoc::scUpdateDisplay);
	}
	else
	{
		pDoc->SelectObject(NULL, CMapDoc::scClear | CMapDoc::scUpdateDisplay);
	}
}