?? 基于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 + -