You are calling
CreatePen
again and again with each drawing.
The simplest solution would be calling
CreatePen
in the constructor of your class and remove it from the draw function:
CMFCApplication2View::CMFCApplication2View()
{
cPen.CreatePen(PS_SOLID, 10, RGB(255, 0, 0));
}
void CMFCApplication2View::OnDraw(CDC* pDC)
{
CPen* pOldPen = pDC->SelectObject(&cPen);
pDC->SelectObject(pOldPen);
}