但是我在程序中进行了测试:
void CTextView::OnLButtonDown(UINT nFlags, CPoint point) 
{
dc.SetMapMode(MM_ANISOTROPIC);
dc.SetViewportExt(100,100);
dc.SetWindowExt(1000,1000); strPoint1.Format("You are at(%d,%d)\nButtonDown\n",point.x,point.y);
MessageBox(strPoint1);

MyPoint=point;
dc.LPtoDP(&MyPoint);
strPoint2.Format("You are at(%f,%f)\nDevice\n",(double)MyPoint.x,(double)MyPoint.y);
MessageBox(strPoint2);

MyPoint=point;
dc.DPtoLP(&MyPoint);
strPoint3.Format("You are at(%f,%f)\nLogical\n",(double)MyPoint.x,(double)MyPoint.y);
MessageBox(strPoint3);
}
程序显示结果看,
若point为(100,100),
Device为(1,1),Logibal为(1000,10000)
为什么?

解决方案 »

  1.   

    当然向下,MSDN中的其他向上的模式都专门有说明,没说明当然向下。
      

  2.   

    只有TEXT模式是向下的,其他模式都是向上的。
      

  3.   

    The MM_ISOTROPIC and MM_ANISOTROPIC mapping modes differ from the other mapping modes in one important respect: It's you, not Windows, who determines how logical coordinates are converted into device coordinates. For this reason, these mapping modes are sometimes called the "roll-your-own" or "programmable" mapping modes. Want a mapping mode in which 1 unit equals 1 centimeter? No problem: Just use the MM_ANISOTROPIC mapping mode and set its scaling parameters accordingly. The most common use for the MM_ISOTROPIC and MM_ANISOTROPIC mapping modes is for drawing output that automatically scales to match the window size. The following code fragment uses the MM_ANISOTROPIC mapping mode to draw an ellipse that touches all four borders of the window in which it is drawn: CRect rect;
    GetClientRect (&rect);
    dc.SetMapMode (MM_ANISOTROPIC);
    dc.SetWindowExt (500, 500);
    dc.SetViewportExt (rect.Width (), rect.Height ());
    dc.Ellipse (0, 0, 500, 500); 
    See how it works? No matter what physical size the window is, you've told Windows that the window's logical size is 500 units by 500 units. Therefore, a bounding box that stretches from (0,0) to (500,500) encompasses the entire window. Initializing a device context in this way places the origin at the upper left corner of the window and orients the axes so that positive x points to the right and positive y points downward. If you'd rather have the y axis point upward (as it does in the metric mapping modes), you can reverse its direction by negating the y value passed to either SetWindowExt or SetViewportExt: CRect rect;
    GetClientRect (&rect);
    dc.SetMapMode (MM_ANISOTROPIC);
    dc.SetWindowExt (500, -500);
    dc.SetViewportExt (rect.Width (), rect.Height ());
    dc.Ellipse (0, 0, 500, -500); 
    Now you must use negative y coordinates to draw in the window. Only the MM_ISOTROPIC and MM_ANISOTROPIC mapping modes allow the directions of the x and y axes to be reversed. That's why the table in the previous section listed these two mapping modes' axis orientations as user defined. The only difference between the MM_ISOTROPIC and MM_ANISOTROPIC mapping modes is that in the former, the scaling factors for the x and y directions are always the same. In other words, 100 horizontal units equals the same physical distance as 100 vertical units. Isotropic means "equal in all directions." The MM_ISOTROPIC mapping mode is ideal for drawing circles and squares. The following code draws a circle that spans the width or height of a window, whichever is smaller: CRect rect;
    GetClientRect (&rect);
    dc.SetMapMode (MM_ISOTROPIC);
    dc.SetWindowExt (500, 500);
    dc.SetViewportExt (rect.Width (), rect.Height ());
    dc.Ellipse (0, 0, 500, 500);