?? 基于visual c++的gdi常用坐標系統及應用 (2).htm
字號:
<!--_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常用坐標系統及應用 (2).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常用坐標系統及應用 (2).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常用坐標系統及應用 (2).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常用坐標系統及應用 (2)</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 -->
<P> 三、更改坐標系統<BR> <BR> </B>正如上面所看到的,默認的坐標系統坐標原點位于窗口的左上角,水平軸的正方向向右,垂直軸的正方向向下。為了進一步說明這一點,讓我們來繪制一個半徑為50個單位,圓心位于(0,0)點,同時繪制一個連接(0,0)(100,100)兩點的直線。<BR> <BR></P>
<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> // A circle whose center is at the origin (0, 0)</DIV>
<DIV> dc.Ellipse(-50, -50, 50, 50);</DIV>
<DIV> // A line that starts at (0, 0) and ends at (100, 100)</DIV>
<DIV> dc.MoveTo(0, 0);</DIV>
<DIV> dc.LineTo(100, 100);</DIV>
<DIV>}</DIV></TD></TR></TBODY></TABLE><BR></DIV>
<P>
<TABLE width="90%" align=center border=0>
<TBODY>
<TR>
<TD>
<DIV align=center><IMG alt=基于VisualC++的GDI常用坐標系統及應用(2)
src="基于Visual C++的GDI常用坐標系統及應用 (2).files/905259103.gif"
border=1><BR><B>圖四、代碼效果圖</B></DIV></TD></TR></TBODY></TABLE> </P>
<DIV> 這種默認的坐標原點在大多數圖形操作情況下是適用的,但并不是總適用,有時你需要控制坐標系統的原點,例如,很多<A
class=akey
href="http://tech.sina.com.cn/it/2004-07-29/1734395211.shtml"
target=_blank>CAD</A>(圖形輔助設計)應用程序就需要用戶來定義坐標系統的原點。<BR> </DIV>
<P> MFC提供了各種函數來處理坐標定位及擴展繪制區域的問題,包括在屏幕上任意位置設置坐標原點的函數。因為你是在一個設備上下文上進行繪圖操作,因此,你所需要做的就是調用CDC::SetViewportOrg()函數。這個函數重載了兩個版本,這允許你使用X、Y坐標或是一個定義的Point點。這個函數的語法如下:<BR> <BR></P>
<DIV>
<TABLE borderColor=#ffcc66 width="90%" align=center bgColor=#dadacf
border=1>
<TBODY>
<TR>
<TD>
<DIV>SetViewportOrg(int X, int Y);</DIV>
<DIV>SetViewportOrg(CPoint Pt);</DIV></TD></TR></TBODY></TABLE></DIV>
<P> </P>
<DIV> 調用這個函數時只需要簡單地說明哪兒是你想定義的坐標原點,如果使用函數的第二個版本,參數可以是一個POINT結構或是一個MFC提供的Tpoint類。為了演示這個函數的效果,讓我們將上例的坐標原點沿X軸正方向移<!-- -->動200個單位,Y軸正方向移<!-- -->動150個單位,這時繪制函數如下:</DIV>
<P> </P>
<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); //繪圖的設備上下文;</DIV>
<DIV> dc.SetViewportOrg(200, 150);</DIV>
<DIV> // 圓心位于坐標原點(0, 0)</DIV>
<DIV> dc.Ellipse(-50, -50, 50, 50);</DIV>
<DIV> // 連接(0, 0) 和 (100, 100)點的直線;</DIV>
<DIV> dc.MoveTo(0, 0);</DIV>
<DIV> dc.LineTo(100, 100);</DIV>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -