📄 right9-1.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>第 9 章</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">第 9 章</span><span style="background-color: #CCFF99">
</span>><span style="background-color: #CCFF99"> 第 1 节 </span>><span style="background-color: #CCFF99">
9.1 </span><span style="background-color: #CCFF99">Windows
程序设计基本概念</span></p>
<hr color="#008000" size="1">
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">1.
Visual C++<font FACE="??ì?,SimSun" LANG="ZH-CN">应用程序设计方法</font></font></p>
<p style="line-height: 100%; margin-top: 5; margin-bottom: 0"><font size="2"><font LANG="ZH-CN">(1)使用</font>Windows<font LANG="ZH-CN">提供的</font>Windows
API<font LANG="ZH-CN">函数</font></font></p>
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">Windows
API<font LANG="ZH-CN">是</font>Windows<font LANG="ZH-CN">系统和</font>Windows<font LANG="ZH-CN">应用程序间的标准程序接口,应用程序可以通过此接口访问系统</font></font></p>
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font lang="ZH-CN" size="2">(2)</font><font size="2"><font LANG="ZH-CN">使用</font>Microsoft<font LANG="ZH-CN">提供的</font>MFC<font LANG="ZH-CN">类库</font></font></p>
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">MFC<font LANG="ZH-CN">类库集成了大量已经预先定义好的类,用户可以根据编程的需要调用相应的类,或根据需要自定义有关的类。</font></font></p>
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> </p>
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">2.
Windows<font FACE="??ì?,SimSun" LANG="ZH-CN">程序设计基本概念</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 5; margin-bottom: 0"><font size="2">(<font LANG="ZH-CN">1)
窗口</font></font></p>
<p 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: 10; margin-bottom: 0"><font LANG="ZH-CN" size="2">(2)
对象与句柄</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>Windows<font LANG="ZH-CN">的规范部件,包括各种窗口、菜单、按钮、对话框以及程序模块等。</font></font></p>
<font SIZE="3">
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">句柄是指</font>Windows<font LANG="ZH-CN">使用的一个唯一的整数值,是一个</font>4<font LANG="ZH-CN">字节长的数值,用于标识应用程序中不同的对象和同类对象中不同的实例,诸如一个窗口、按钮、图标、滚动条、输出设备、控件或者文件等。应用程序通过句柄能够访问相应的对象信息。<a href="table9-1.htm" target="_blank">表</a></font><a href="table9-1.htm" target="_self">9-1</a><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">(3)
事件驱动</font></p>
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">Windows<font FACE="??ì?,SimSun" LANG="ZH-CN">应用程序以消息为基础,以事件驱动之。</font>Windows<font LANG="ZH-CN">应用程序启动之后将进入一个消息循环,等待系统或应用程序的消息,消息的产生是因为事件发生的结果,</font>Windows<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">(4)
消息及其在Windows编程中的应用</font></p>
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">Windows<font FACE="??ì?,SimSun" LANG="ZH-CN">应用程序的运行是依靠事件来驱动,</font>Windows<font LANG="ZH-CN">应用程序不断等待(利用一个</font>while<font LANG="ZH-CN">循环),如果有事件发生,操作系统会以消息的形式传递给应用程序,应用程序会捕获相应的消息,然后响应消息(调用相应的函数)。</font></font></p>
<p style="line-height: 100%; margin-top: 5; margin-bottom: 0"><font size="2"><font LANG="ZH-CN">系统传递给应用程序的消息数据是一个</font>MSG<font LANG="ZH-CN">结构体数据类型的数据。结构体</font>MSG<font LANG="ZH-CN">的定义如下:</font></font></p>
<blockquote>
<blockquote>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2" color="#008000">typedef
struct tagMSG // <font LANG="ZH-CN">消息</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2" color="#008000">{ </font></p>
<blockquote>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2" color="#008000">HWND
hwnd;</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2" color="#008000">UINT
message;</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2" color="#008000">WPARAM
wParam;</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2" color="#008000">LPARAM
lParam;</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2" color="#008000">DWORD
time;</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2" color="#008000">POINT
pt;</font></p>
</blockquote>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2" color="#008000">}
MSG;</font></p>
</blockquote>
</blockquote>
<hr size="1" color="#008000">
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> <span style="position: absolute; left: 37; top: 727"><a href="right8-5.htm" target="_self"><img border="0" src="rightd1.gif" width="113" height="70"></a></span>
<span style="position: absolute; left: 483; top: 729"><a href="right9-2.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 + -