// Create a new element on the heap
CElement* CSketcherView::CreateElement(void)
{
   // Get a pointer to the document for this view
   CSketcherDoc* pDoc = GetDocument();
   ASSERT_VALID(pDoc);                 // Verify the pointer is good

   // Now select the element using the type stored in the document
   switch(pDoc->GetElementType())
   {
      case RECTANGLE:
         return new CRectangle(m_FirstPoint, m_SecondPoint,
                                       pDoc->GetElementColor(), pDoc->GetPenWidth());

      case CIRCLE:
         return new CCircle(m_FirstPoint, m_SecondPoint,
                                       pDoc->GetElementColor(), pDoc->GetPenWidth());

      case CURVE:
         return new CCurve(m_FirstPoint, m_SecondPoint, 
                                       pDoc->GetElementColor(), pDoc->GetPenWidth());
      case LINE:
         return new CLine(m_FirstPoint, m_SecondPoint,
                                       pDoc->GetElementColor(), pDoc->GetPenWidth());

      default:
         // Something's gone wrong
         AfxMessageBox(_T("Bad Element code"), MB_OK);
         AfxAbort();
         return NULL;
   }
}