📄 基于visual c++的gdi常用坐标系统及应用 (4).htm
字号:
</SCRIPT>
<SCRIPT language=JavaScript><!--_S_gsSINAPUID();function _S_gPageInfo(PageID,_sp_rfurl){var now=new Date();var sid=_S_gSINAUID();var pid="pid:"+PageID;var currUrl=_S_PWD_.URL;var currPath=_S_gUrl2Pth(currUrl);var st="st:0";var et="et:"+now.getTime();var hp="hp:"+_S_isHome();var lb="lb:1";var pgls="PGLS:"+_S_gMeta("stencil");var key="keys:"+_S_gMeta("keywords");return sid+"|"+pid+"|"+currPath+"|"+st+"|"+et+"|"+_sp_rfurl+"|"+hp+"|"+lb+"|"+pgls+"|"+key+"|*|";}function _S_gEnvInfo(){var now=new Date();var pct=0;var ckValue="sz:"+screen.width+"x"+screen.height+"||";ckValue=ckValue+"dp:"+screen.colorDepth+"||";ckValue=ckValue+"ac:"+_S_BN_.appCodeName+"||";ckValue=ckValue+"an:"+_S_NAN_+"||";var ckTmp=_S_NAV_; var pos=0; var tmpValue=""; var len=ckTmp.length; var pos2=0; pos2=ckTmp.indexOf(";",pos); while(pos2>=0) {tmpValue=tmpValue + ckTmp.substring(pos,pos2)+",";pos=pos2+1;pos2=ckTmp.indexOf(";",pos) } tmpValue=tmpValue + ckTmp.substring(pos,len);ckValue=ckValue+"av:"+tmpValue+"||";ckValue=ckValue+"cpu:"+_S_BN_.cpuClass+"||"; ckValue=ckValue+"pf:"+_S_BN_.platform+"||";ckValue=ckValue+"jv:"+_S_gJVer()+"||";ckValue=ckValue+"ct:"+_S_gConType()+"||";ckValue=ckValue+"lg:"+_S_BN_.systemLanguage+"||";ckValue=ckValue+"tz:"+now.getTimezoneOffset()/60;return ckValue;}function setBaseCookie(shrink, _sp_mpid){if (("undefined"==_sp_mpid)||(""==_sp_mpid)){return; } var ckTmp=_S_gsSINAUID();var sudsid=_S_gsSINAPUID();var ckValue=_S_gEnvInfo();var unStr=_S_gUniproUN();var uidStr=_S_gUniproUNid();var envStr="UNIPROINFO="+ckValue+"||un:"+unStr+"||uid:"+uidStr+";";var refUrl=_S_PWD_.referrer;var cPageStr=_S_gPageInfo(_sp_mpid,refUrl);var lbStr=sudsid+"|*|"+cPageStr;lbStr=envStr+"UNIPROPATH="+lbStr+";";_S_p2Bcn(lbStr,cp_rf);}function shrinkCookie(p1,p2,p3,p4,p5){try {metaList=_S_gMeta("sinachannel");if(""!=metaList) {setBaseCookie(1, metaList);} else{setBaseCookie(1, _S_CID_+_S_DPID_); } } catch(e){}}shrinkCookie();--></SCRIPT>
<!-- SUDS_CODE_END -->
<CENTER><!--导航start-->
<STYLE>.h3 {
FONT-SIZE: 7px; COLOR: #ffbd00
}
</STYLE>
<TABLE cellSpacing=0 cellPadding=0 width=750 border=0>
<TBODY>
<TR>
<TD>
<SCRIPT>
function getCookie(name) {
var search;
search = name + "="
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length ;
end = document.cookie.indexOf(";", offset) ;
if (end == -1)
end = document.cookie.length;
return document.cookie.substring(offset, end);
}
else
return "";
}
function unipro_clearCookie(name ) {
document.cookie=name+"=; " + "domain=sina.com.cn; path=/; ";
//bites = document.cookie.split("; ");
}
function getMobileNum(ckName){
var userInfo = getCookie(ckName).split(":");
return userInfo[2];
}
function unipro_UniProLogout() {
unipro_clearCookie("SINAPRO");
unipro_clearCookie("SINA-AVATAR");
unipro_clearCookie("SINAPROC");
unipro_clearCookie("nick");
unipro_clearCookie("SINA_NU");
unipro_clearCookie("SINA_OU");
unipro_clearCookie("appmask");
unipro_clearCookie("gender");
unipro_clearCookie("UNIPROTM");
unipro_clearCookie("UNIPROU");
unipro_clearCookie("SINA_USER");
unipro_clearCookie("SMS_COOKIE");
return true;
}
function getUniproUrl_stand(){
window.location='http://unipro.sina.com.cn/';
return false;
}
function getUniproUrl_welcome(){
unipro_UniProLogout();
window.location='http://unipro.sina.com.cn';
return false;
}
function print_stand_unipro_head()
{
document.write("<table border=0 cellpadding=0 cellspacing=0><tr align=center><td><a href=http://www.sina.com.cn class=a01>首页</a></td><td width=14></td><td><a href=http://news.sina.com.cn class=a01>新闻</a></td><td width=14></td><td><a href=http://sports.sina.com.cn class=a01>体育</a></td><td width=14></td><td><a href=http://ent.sina.com.cn class=a01>娱乐</a></td><td width=14></td><td><a href=http://bn.sina.com.cn/ class=a01>视频</a></td><td width=14></td><td><a href=http://finance.sina.com.cn/ class=a01>财经</a></td><td width=14></td><td><a href=http://tech.sina.com.cn/ class=a01>科技</a></td><td width=14></td><td><a href=http://auto.sina.com.cn/ class=a01>汽车</a></td><td width=14></td><td><a href=http://house.sina.com.cn/ class=a01><font color=red>房产</font></a></td><td width=14></td><td><a href=http://games.sina.com.cn class=a01>游戏</a></td><td width=14></td><td><a href=http://eladies.sina.com.cn/ class=a01>女性</a></td><td width=14></td><td><a href=http://book.sina.com.cn/ class=a01>读书</a><td width=14></td><td><a href=http://y.sina.com.cn/ class=a01>校园</a></td><td width=14></td><td><a href=http://weather.sina.com.cn/ class=a01>天气</a></td><td width=14></td><td><a href=http://sms.sina.com.cn class=a01>短信</a></td><td width=14></td><td><a href=http://mail.sina.com.cn class=a01>邮箱</a></td><td width=14></td><td><a href=http://search.sina.com.cn class=a01>搜索</a></td><td width=14></td><td><a href=http://news.sina.com.cn/guide/ class=a01>导航</a></td><td width=14></td></tr></table>");
document.write("</td><td align=right>");
document.write("<table height=25 border=0 cellpadding=0 cellspacing=0>");
document.write("<tr><td><td align=right> <a href=# onClick='return getUniproUrl_stand()'>通行证登录</a></td></tr>");
document.write("</table>");
}
function print_stand_unipro_welcome()
{
var unipro_login_nickname = getCookie( "nick" );
var unipro_login_pos = unipro_login_nickname.indexOf( "(" );
if ( unipro_login_pos != -1 )
{
unipro_login_nickname = unipro_login_nickname.substr( 0, unipro_login_pos );
}
document.write("<table border=0 cellpadding=0 cellspacing=0><tr align=center><td><a href=http://www.sina.com.cn class=a01>首页</a></td><td width=14></td><td><a href=http://news.sina.com.cn class=a01>新闻</a></td><td width=14></td><td><a href=http://sports.sina.com.cn class=a01>体育</a></td><td width=14></td><td><a href=http://ent.sina.com.cn class=a01>娱乐</a></td><td width=14></td><td><a href=http://bn.sina.com.cn/ class=a01>视听</a></td><td width=14></td><td><a href=http://finance.sina.com.cn/ class=a01>财经</a></td><td width=14></td><td><a href=http://tech.sina.com.cn/ class=a01>科技</a></td><td width=14></td><td><a href=http://auto.sina.com.cn/ class=a01>汽车</a></td><td width=14></td><td><a href=http://house.sina.com.cn/ class=a01><font color=red>房产</font></a></td><td width=14></td><td><a href=http://games.sina.com.cn class=a01>游戏</a></td><td width=14></td><td><a href=http://weather.sina.com.cn/ class=a01>天气</a></td><td width=14></td><td><a href=http://sms.sina.com.cn class=a01>短信</a></td><td width=14></td><td><a href=http://mail.sina.com.cn class=a01>邮箱</a></td><td width=14></td><td><a href=http://search.sina.com.cn class=a01>搜索</a></td><td width=14></td><td><a href=http://news.sina.com.cn/guide/ class=a01>导航</a></td><td width=14></td><td></td></tr></table>");
document.write("</td><td align=right>");
document.write("<table height=25 border=0 cellpadding=0 cellspacing=0>");
document.write("<tr>");
if ( unipro_login_nickname!="" && unipro_login_nickname!="null" && unipro_login_nickname!=null && unipro_login_nickname!="undefined" ) {
document.write("<td align=right> "+unipro_login_nickname+"</td><td width=4></td><td><a href=# onClick='return getUniproUrl_welcome()'><font color=#0000ff>安全退出</font></a>");
} else {
document.write( "<td align=right> 新浪过客" +"</td><td width=4></td><td><a href=# onClick='return getUniproUrl_welcome()'><font color=#0000ff>安全退出</font></a>");
}
document.write("</td></tr>");
document.write("</table>");
}
</SCRIPT>
<SCRIPT language=javascript>
if (getCookie("SINAPRO") == "") {
print_stand_unipro_head();
} else {
print_stand_unipro_welcome();
}
</SCRIPT>
</TD></TR></TBODY></TABLE><!--导航end--><!--头部结束--><!--科技新闻内页顶部通栏开始--><!--17F810F98351-->
<OBJECT
codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0
height=80 width=750 classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000><PARAM NAME="movie" VALUE="http://ad4.sina.com.cn/200506/13/21036.swf"><PARAM NAME="quality" VALUE="high"><PARAM NAME="wmode" VALUE="opaque">
<EMBED src="http://ad4.sina.com.cn/200506/13/21036.swf" FlashVars="h"
quality=high WIDTH="750" HEIGHT="80" TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>
</OBJECT><!--$$ weixing/2005-6-20 ~ 2005-6-20/B $--><!--科技新闻内页顶部通栏结束-->
<TABLE cellSpacing=0 cellPadding=0 width=750 border=0>
<TBODY>
<TR>
<TD width=150 height=34><A href="http://tech.sina.com.cn/"><IMG height=34
alt=科技时代 src="基于Visual C++的GDI常用坐标系统及应用 (4).files/sina_kjsd.gif" width=144
border=0></A></TD>
<TD vAlign=bottom width=440><FONT color=#0000ff><A class=a02
href="http://home.sina.com.cn/">新浪首页</A> > <A class=a02
href="http://tech.sina.com.cn/">科技时代</A> > <A class=a02
href="http://tech.sina.com.cn/introduction/">学园</A> > 正文</FONT></TD>
<TD vAlign=bottom align=right width=150><A href="http://www.yesky.com/"
target=_blank><IMG height=28
src="基于Visual C++的GDI常用坐标系统及应用 (4).files/U1084P2T50D213F629DT20041213105743.gif"
border=0></A></TD>
<TD width=10></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=750 border=0>
<TBODY>
<TR>
<TD height=8></TD></TR>
<TR>
<TD bgColor=#747474 height=1><IMG height=1
src="基于Visual C++的GDI常用坐标系统及应用 (4).files/c.gif"
width=1></TD></TR></TBODY></TABLE>
<DIV id=outer style="WIDTH: 750px; POSITION: relative">
<TABLE cellSpacing=0 cellPadding=0 width=750 border=0>
<TBODY>
<TR>
<TD vAlign=top align=middle width=620 bgColor=#edf0f5 rowSpan=2><BR>
<DIV id=article>
<TABLE cellSpacing=0 cellPadding=0 width=560 border=0>
<TBODY>
<TR>
<TH class=f24><FONT color=#05006c>
<H1>基于Visual C++的GDI常用坐标系统及应用 (4)</H1></FONT></TH></TR>
<TR>
<TD>
<HR SIZE=1 bgcolor="#d9d9d9">
</TD></TR>
<TR>
<TD align=middle height=20>http://www.sina.com.cn
2005年06月20日 11:43 <FONT color=#a20010>天极yesky</FONT></TD></TR>
<TR>
<TD height=15></TD></TR>
<TR>
<TD class=l17><FONT class=f14 id=zoom><!-- 正文内部文字导航 : begin --><!-- 正文内部文字导航 : end -->
<DIV></DIV>
<DIV></DIV>
<DIV>
<DIV><B> 四、自定义坐标系统</B></DIV>
<DIV> 目前为止,我们使用的映射模式可以允许我们选择坐标轴的方向,但仅仅是Y轴的方向。而且,我们不能更改坐标系统的单位,这是因为各种映射模式(MM_TEXT, MM_HIENGLISH, MM_LOENGLISH, MM_HIMETRIC, MM_LOMETRIC, and MM_TWIPS)有固定的属性集,例如坐标轴的方向和坐标单位等。在CAD应用程序中,如果你需要灵活设置坐标轴方向及坐标单位的话,应该怎么做呢?</DIV>
<DIV> 仔细研究下面的OnPaint()事件代码,它绘制了一个200X200像素大小的红边、浅绿色背景的正方形,这个正方形的顶点在(-100,-100)处,右底端位于(100,100)处。同时,从坐标原点处绘制一个45度的直线。</DIV>
<DIV>
<TABLE borderColor=#ffcc66 width="90%" align=center bgColor=#dadacf
border=1>
<TBODY>
<TR>
<TD>
<DIV>void CExoDraw1View::OnPaint() </DIV>
<DIV>{</DIV>
<DIV> CPaintDC dc(this); // device context for painting</DIV>
<DIV> CPen PenRed(PS_SOLID, 1, RGB(255, 0, 0));</DIV>
<DIV> CBrush BrushAqua(RGB(0, 255, 255));</DIV>
<DIV> dc.SelectObject(PenRed);</DIV>
<DIV> dc.SelectObject(BrushAqua);</DIV>
<DIV> // Draw a square with a red border and an aqua background</DIV>
<DIV> dc.Rectangle(-100, -100, 100, 100);</DIV>
<DIV> CPen BluePen(PS_SOLID, 1, RGB(0, 0, 255));</DIV>
<DIV> dc.SelectObject(BluePen);</DIV>
<DIV> // Diagonal line at 45 degrees starting at the origin (0, 0)</DIV>
<DIV> dc.MoveTo(0, 0);</DIV>
<DIV> dc.LineTo(200, 200);</DIV>
<DIV>}</DIV></TD></TR></TBODY></TABLE><BR></DIV>
<TABLE width="90%" align=center border=0>
<TBODY>
<TR>
<TD>
<DIV align=center><B><IMG alt=基于VisualC++的GDI常用坐标系统及应用(4)
src="基于Visual C++的GDI常用坐标系统及应用 (4).files/3996410362.gif"
border=1><BR>图十七、代码效果图</B></DIV></TD></TR></TBODY></TABLE>
<DIV> 正如你所看到的,我们只得到了正方形的右下部分,同时直线指向时钟的三点到六点之间的方向。假定你想将坐标原点设置与窗口中央位置,或者是更精确一点,设置于点(340, 220)处,我们已经知道可以使用CDC::SetViewportOrg()(记住,这个函数只用来更改坐标原点,它并不影响坐标轴的方向及坐标单位。同时,需要注意的是,它使用的坐标单位是像素)函数,下面是一个例子(我们没有规定映射模式,所以程序使用的是默认的MM_TEXT映射模式)。</DIV>
<DIV>
<TABLE borderColor=#ffcc66 width="90%" align=center bgColor=#dadacf
border=1>
<TBODY>
<TR>
<TD>
<DIV>void CExoDraw1View::OnPaint() </DIV>
<DIV>{</DIV>
<DIV> CPaintDC dc(this); // device context for painting</DIV>
<DIV> dc.SetViewportOrg(340, 220);</DIV>
<DIV> CPen PenRed(PS_SOLID, 1, RGB(255, 0, 0));</DIV>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -