但是我在程序中进行了测试:
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)
为什么?
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)
为什么?
解决方案 »
- CreateProcessAsUser的问题
- 在已经加载bmp图片的PICTURE控件上画圆,为何圆显示不出来?
- 急求wpcap.lib和packet.lib,谁有啊!拜托了!
- 菜鸟求教,如何把CString 类型转换成LPCWSTR类型
- 哪位仁兄知道eclipse这个东东,介绍一下,给点资料或是网站等,感激不尽。
- 在程序中怎样调用其他程序,比如JDK安装程序??
- 一个应用如何结束另外的应用?
- 100分求c++画扇形的算法或源代码
- VC/MFC绘图闪烁
- 石器时代之SADE,那位高手知道其原理,大家探讨一下吧!!!
- 关于DirectDraw实现Alpha透明方法
- 在vc中用ADO访问数据库,用DATAGRID 显示数据记录后,怎样获得选中的CELL中的文本信息?
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);