Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 9 Strings Visual C++ and MFC Fundamentals


You should not rely on the above picture. After calling the CDC::SetMapMode() function
with MM_ISOTROPIC (or MM_ANISOTROPIC) as argument, you are not supposed to
stop there. The purpose of these two map modes is to let you control the orientation of the
axes and the conversion of the units.

The difference between both mapping modes is that, when using the MM_ISOTROPIC
map mode, one unit in the horizontal axis is equivalent to one unit in the vertical axis.
This is not the case for the MM_ANISOTROPIC map mode which allows you to control
however the units should be converted on each individual axis.

Therefore, after calling SetMapMode() and specifying the MM_ISOTROPIC (or
MM_ANISOTROPIC), you must call the CDC:SetWindowExt() member function. This
method specifies how much each new unit will be multiplied by the old or default unit
system. The CDC::SetWindowExtEx() member function comes in two versions with the
following syntaxes:

CSize SetWindowExt(int cx, int cy);
CSize SetWindowExt(SIZE size);

If using the first version, the first argument to this function, cx, specifies the logical
conversion multiplier used for each unit on the horizontal axis. The second argument, cy,
specifies the logical conversion multiplier used for each unit on the vertical axis.

The second version of the method can be used if you know the desired logical width and
height as a SIZE structure. Here is an example:

void CExoView::OnDraw(CDC* pDC)
{
CExoDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);

CPen PenRed(PS_SOLID, 1, RGB(255, 0, 0));
CBrush BrushAqua(RGB(0, 255, 255));
CBrush *brOld;
CPen *pnOld;

pnOld = pDC->SelectObject(&PenRed);
brOld = pDC->SelectObject(&BrushAqua);
Free download pdf