Visual C++ and MFC Fundamentals Chapter 9: Strings
As seen already, the SetViewportOrg() member function can be used to change the origin
of the device context. It also uses an orientation of axes so that the horizontal axis moves
positively from (0, 0) to the right. The vertical axis moves positively from (0, 0) down:
To illustrate this, we will draw a green line at 45° from the origin:
void CExoView::OnDraw(CDC* pDC)
{
CExoDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDC->SetViewportOrg(220, 150);
// Use a red pen
CPen PenRed(PS_SOLID, 1, RGB(255, 0, 0));
CPen *pOld = pDC->SelectObject(&PenRed);
// A circle whose center is at the origin (0, 0)
pDC->Ellipse(-100, -100, 100, 100);
// Use a blue pen
CPen PenBlue(PS_SOLID, 1, RGB(0, 0, 255));
pOld = pDC->SelectObject(&PenBlue);