📄 right18-4.htm
字号:
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>第 18 章</title>
<base target="rbottom">
<style>
<!--
.右标题 { font-size: 10pt; color: #000080; text-indent: 0; margin: 0 }
.右内容 { font-size: 10pt; text-align: left; text-indent: 0; line-height: 100%; margin:
0 }
-->
</style>
</head>
<body>
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> </p>
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"><span style="position: absolute; left: 4; top: -8"><img border="0" src="1.gif" width="63" height="70"></span></p>
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> </p>
<p style="line-height: 100%; text-indent: 0; margin: 0" class="右标题" align="left">
<span style="background-color: #CCFF99">第 18 章</span><span style="background-color: #CCFF99">
</span>><span style="background-color: #CCFF99"> 第 4 节 </span>><span style="background-color: #CCFF99">
18.4 常见的绘图任务</span></p>
<hr color="#008000" size="1">
<p style="line-height: 100%; text-indent: 0; margin: 0" class="右标题" align="left"> </p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font LANG="ZH-CN" size="2">常见的绘图任务包括:输出文本、输出图形、输出图像等。</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">1.
<font LANG="ZH-CN">输出文本</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 10; margin-bottom: 0"><font LANG="ZH-CN" size="2">(1)
文本输出要素</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2"><font LANG="ZH-CN">①</font><font LANG="ZH-CN">字体大小计算:通过调用</font>GetTextMetrics(
)<font LANG="ZH-CN">返回当前使用字体的尺寸描述。</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2"><font LANG="ZH-CN">②</font></font><font LANG="ZH-CN" size="2">字体颜色设置:</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2"><font LANG="ZH-CN">
设置前景色:</font> CDC::SetTextColor(int nColor);</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">
<font LANG="ZH-CN">设置背景色: </font><font lang="ZH-CN"> </font>CDC::SetBkColor(int
nColor);</font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 10; margin-bottom: 0"><font LANG="ZH-CN" size="2">(2)
文字输出函数</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2"><font LANG="ZH-CN">①
</font>TextOut( )</font></p>
<font SIZE="3">
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">②
</font>TabbedTextOut( )</font></p>
<font SIZE="3">
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">③</font>
ExtTextOut( )</font></p>
<font SIZE="3">
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><span style="mso-bidi-font-size: 10.0pt; mso-bidi-font-family: Times New Roman; mso-font-kerning: 10.5pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">④
</span>DrawText( )</font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 10; margin-bottom: 0"><font LANG="ZH-CN" size="2">(3)
文本输出举例</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2"><font LANG="ZH-CN"><a href="example18-1.htm" target="_blank">【例</a></font><a href="example18-1.htm" target="_blank">18-1<font LANG="ZH-CN">】</font></a><font LANG="ZH-CN">在屏幕上显示如图</font>18-1<font LANG="ZH-CN">所示的文字。</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"> </p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">2.
<font LANG="ZH-CN">输出图形</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 10; margin-bottom: 0"><font LANG="ZH-CN" size="2">(1)
画点 </font><font size="2"><font lang="ZH-CN"> </font>SetPixel( )</font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 10; margin-bottom: 0"><font LANG="ZH-CN" size="2">(2)
画线</font><font size="2"><font lang="ZH-CN"> </font>MoveToEx( ) LineTo(
)</font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 10; margin-bottom: 0"><font lang="ZH-CN" size="2">(3)
画弧 Arc( )</font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 10; margin-bottom: 0"><font lang="ZH-CN" size="2">(4)
封闭图形 Rectangle( )、RoundRect( )、Ellipse( )等</font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 10; margin-bottom: 0"><font LANG="ZH-CN" size="2">(5)
其它常用的绘图函数</font><font size="2"><font lang="ZH-CN"> </font>FillRect(
)、Draw3dRect( )等</font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 10; margin-bottom: 0"><font lang="ZH-CN" size="2">(</font><font LANG="ZH-CN" size="2">6)
图形输出举例</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2"><font LANG="ZH-CN"><a href="example18-2.htm" target="_blank">【例</a></font><a href="example18-2.htm" target="_blank">18-2<font LANG="ZH-CN">】</font></a><font LANG="ZH-CN">在屏幕上显示如图</font>18-4<font LANG="ZH-CN">所示的图形。</font></font></p>
<blockquote>
<blockquote>
</blockquote>
</blockquote>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">3.
<font LANG="ZH-CN">输出图像</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 10; margin-bottom: 0"><font lang="ZH-CN" size="2">(</font><font LANG="ZH-CN" size="2">1)
输出图像的步骤</font></p>
<font SIZE="3">
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">①</font>
<font LANG="ZH-CN">创建一个新的</font>CBitmap<font LANG="ZH-CN">对象。</font></font></p>
<font SIZE="3">
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">②</font>
<font LANG="ZH-CN">将所需的位图图像文件和该对象关联。</font></font></p>
<font SIZE="3">
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">③</font>
<font LANG="ZH-CN">将其选入用于显示的</font>DC<font LANG="ZH-CN">。</font></font></p>
<font SIZE="3">
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">④</font>
<font LANG="ZH-CN">执行图像显示操作。</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 10; margin-bottom: 0"><font LANG="ZH-CN" size="2">(2)
输出图像使用的函数</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">CBitmap
<font LANG="ZH-CN">类的成员函数有:</font></font></p>
<font SIZE="3">
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">①</font>
CBitmap( )<font LANG="ZH-CN">:</font>CBitmap<font LANG="ZH-CN">类的构造函数,用于创建一个</font>CBitmap<font LANG="ZH-CN">对象。</font></font></p>
<font SIZE="3">
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">②</font>
LoadBitmap( )<font LANG="ZH-CN">:将已存在的位图资源与</font>CBitmap<font LANG="ZH-CN">对象关联。</font></font></p>
<font SIZE="3">
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font LANG="ZH-CN" size="2">用法:</font></p>
<blockquote>
<blockquote>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2" color="#008000">LoadBitmap(
UINT nIDResource)</font></p>
</blockquote>
</blockquote>
<p ALIGN="justify" style="line-height: 100%; margin-top: 10; margin-bottom: 0"><font LANG="ZH-CN" size="2">(3)
输出图像举例</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2"><font LANG="ZH-CN"><a href="example18-3.htm" target="_blank">【例</a></font><a href="example18-3.htm" target="_blank">18-3<font LANG="ZH-CN">】</font></a><font LANG="ZH-CN">在屏幕上显示如图</font>18-5<font LANG="ZH-CN">所示的图形。</font></font></p>
<hr size="1" color="#008000">
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> </p>
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> <span style="position: absolute; left: 28; top: 865"><a href="right18-3.htm" target="_self"><img border="0" src="rightd1.gif" width="113" height="70"></a></span>
<span style="position: absolute; left: 502; top: 867"><a href="right18-5.htm" target="_self"><img border="0" src="rightd2.gif" width="124" height="63"></a></span></p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -