Although the code below works, I cannot understand why. Can someome try the code and explain to me why it works. It is the BitBlt function that I am most confused about because in the MSDN documentation it states that the first x and y arguments refer to the "logical ? coordinate of the upper-left corner of the destination rectangle.". Note, that I am specifying the "bottom" for the y value. Also, I am specifying a negative height. Not because I know to do this, but because I just happened to come across this through trial-and-error. If anyone can help me understand why the code below works, it would be greatly appreciated.

Code:
void ProfileCtrl::OnPaint()
{
	CRect rect;
	GetClientRect(&rect);

	CPaintDC paintDc(this);
	paintDc.SetMapMode(MM_ISOTROPIC);
	paintDc.SetWindowExt(rect.Size());
	paintDc.SetViewportExt(rect.Width(), -rect.Height());
	paintDc.SetViewportOrg(rect.left, rect.bottom);

	CBitmap bitmap;
	bitmap.CreateCompatibleBitmap(&paintDc, rect.Width(), rect.Height());

	CDC memDc;
	memDc.CreateCompatibleDC(&paintDc);
	memDc.SetMapMode(paintDc.GetMapMode());
	memDc.SetWindowExt(paintDc.GetWindowExt());
	memDc.SetViewportExt(paintDc.GetViewportExt());
	memDc.SetViewportOrg(paintDc.GetViewportOrg());

	CBitmap* pOldBitmap = memDc.SelectObject(&bitmap);
	memDc.DPtoLP(&rect);
	memDc.FillSolidRect(&rect, RGB(0,0,0));
	
	CPen pen(PS_SOLID, 1, RGB(255,0,0));
	memDc.SelectObject(&pen);
	memDc.LineTo(100,100);

	paintDc.BitBlt(rect.left, rect.bottom, rect.Width(), -rect.Height(), &memDc, 0, 0, SRCCOPY);
	memDc.SelectObject(pOldBitmap);
}