📄 right9-2.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"> 第 2 节 </span>><span style="background-color: #CCFF99">
9.2 </span><span style="background-color: #CCFF99">Windows 中的事件驱动</span></p>
<hr color="#008000" size="1">
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0" class="右标题"><font size="2">Windows<font FACE="??ì?,SimSun" LANG="ZH-CN">应用程序以消息为基础,以事件驱动之。</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0" class="右标题"> </p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2"><font FACE="??ì?,SimSun" LANG="ZH-CN">事件驱动程序设计是围绕着消息的产生与处理而展开的。一条消息是关于发生的事件的信息。作为一个</font>Windows<font FACE="??ì?,SimSun" LANG="ZH-CN">程序员,其工作就是对正开发的应用程序所要发出或要接收的消息进行排序和管理。</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"> </p>
<font SIZE="3">
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font FACE="??ì?,SimSun" LANG="ZH-CN">在</font>Windows<font FACE="??ì?,SimSun" 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">MSG
msg
//<font FACE="??ì?,SimSun" LANG="ZH-CN">定义一个</font>MSG<font FACE="??ì?,SimSun" LANG="ZH-CN">类型的变量</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2" color="#008000">while
(GetMessage (&msg, NULL, 0, 0)) //<font FACE="??ì?,SimSun" 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">TranslateMessage
(&msg) ; //<font FACE="??ì?,SimSun" LANG="ZH-CN">翻译消息</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2" color="#008000">DispatchMessage
(&msg) ; //<font FACE="??ì?,SimSun" LANG="ZH-CN">将消息传递给窗口函数,以便处理相应的消息</font></font></p>
</blockquote>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2" color="#008000">}</font></p>
</blockquote>
</blockquote>
<font SIZE="3">
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font FACE="??ì?,SimSun" LANG="ZH-CN">面向对象的程序设计方法更适合于</font>Windows<font FACE="??ì?,SimSun" LANG="ZH-CN">的事件驱动机制,因为面向对象将问题分解为一个或多个对象的处理,对象的属性和行为的处理不能使用顺序处理方式,比较适合这种根据用户要求处理问题的方法。</font></font></p>
<p style="line-height: 100%; text-indent: 0; margin: 0" align="left"> </p>
<hr size="1" color="#008000">
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> <span style="position: absolute; left: 39; top: 419"><a href="right9-1.htm" target="_self"><img border="0" src="rightd1.gif" width="113" height="70"></a></span>
<span style="position: absolute; left: 492; top: 420"><a href="right9-3.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 + -