📄 right9-3.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"> 第 3 节 </span>><span style="background-color: #CCFF99">
9.3 </span><span style="background-color: #CCFF99">Windows
应用程序中常见消息</span></p>
<hr color="#008000" size="1">
<p style="line-height: 150%; text-indent: 0; margin: 0" align="left" class="右标题"><font size="2"><font FACE="??ì?,SimSun" LANG="ZH-CN">消息在</font>Windows<font FACE="??ì?,SimSun" LANG="ZH-CN">程序设计中是很关键的因素,在</font>API<font FACE="??ì?,SimSun" LANG="ZH-CN">程序设计方法中要求熟练记忆常见消息,但是在</font>MFC<font FACE="??ì?,SimSun" LANG="ZH-CN">程序设计方法中只是要求了解这些消息的相关含义即可。</font></font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font FACE="oúì?,SimHei" LANG="ZH-CN" size="2">1.
鼠标消息</font></p>
<p ALIGN="left" style="line-height: 100%; margin-top: 0; margin-bottom: 5"><font size="2">
<font face="黑体">
表9-3 常见的<font LANG="ZH-CN">鼠标消息</font></font></font></p>
<table border="1" cellspacing="0" cellpadding="0" style="border-collapse:collapse;
border:none;mso-border-alt:solid windowtext .5pt;mso-padding-alt:0cm 5.4pt 0cm 5.4pt" bgcolor="#CCFFCC">
<thead>
<tr>
<td width="277" valign="top" style="width:207.75pt;border-top:solid windowtext .75pt;
border-left:none;border-bottom:solid windowtext .5pt;border-right:solid windowtext .5pt;
padding:0cm 5.4pt 0cm 5.4pt" align="center">
<p class="MsoHeading8" style="margin-top: 0"><font size="2">鼠标消息名<span lang="EN-US"><o:p>
</o:p>
</span></font></p>
</td>
<td width="298" valign="top" style="width:223.65pt;border-top:solid windowtext .75pt;
border-left:none;border-bottom:solid windowtext .5pt;border-right:none;
mso-border-left-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt" align="center">
<p class="MsoHeading8" style="margin-top: 0"><font size="2">说明<span lang="EN-US"><o:p>
</o:p>
</span></font></p>
</td>
</tr>
</thead>
<tr>
<td width="277" valign="top" style="width:207.75pt;border-top:none;border-left:
none;border-bottom:solid windowtext .5pt;border-right:solid windowtext .5pt;
mso-border-top-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt">
<p class="MsoHeading9" style="margin-top: 0"><span lang="EN-US"><font size="2">WM_LBUTTONDOWN<o:p>
</o:p>
</font></span></p>
</td>
<td width="298" valign="top" style="width:223.65pt;border:none;border-bottom:
solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:
solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt">
<p class="MsoHeading9" style="margin-top: 0"><span style="font-family:宋体;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman""><font size="2">单击鼠标左键时产生的消息</font></span><font size="2"><span lang="EN-US"><o:p>
</o:p>
</span></font></p>
</td>
</tr>
<tr>
<td width="277" valign="top" style="width:207.75pt;border-top:none;border-left:
none;border-bottom:solid windowtext .5pt;border-right:solid windowtext .5pt;
mso-border-top-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt">
<p class="MsoHeading9" style="margin-top: 0"><span lang="EN-US"><font size="2">WM_LBUTTONUP<o:p>
</o:p>
</font></span></p>
</td>
<td width="298" valign="top" style="width:223.65pt;border:none;border-bottom:
solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:
solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt">
<p class="MsoHeading9" style="margin-top: 0"><span style="font-family:宋体;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman""><font size="2">放开鼠标左键时产生的消息</font></span><font size="2"><span lang="EN-US"><o:p>
</o:p>
</span></font></p>
</td>
</tr>
<tr>
<td width="277" valign="top" style="width:207.75pt;border-top:none;border-left:
none;border-bottom:solid windowtext .5pt;border-right:solid windowtext .5pt;
mso-border-top-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt">
<p class="MsoHeading9" style="margin-top: 0"><span lang="EN-US"><font size="2">WM_RBUTTONDOWN<o:p>
</o:p>
</font></span></p>
</td>
<td width="298" valign="top" style="width:223.65pt;border:none;border-bottom:
solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:
solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt">
<p class="MsoHeading9" style="margin-top: 0"><span style="font-family:宋体;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman""><font size="2">单击鼠标右键时产生的消息</font></span><font size="2"><span lang="EN-US"><o:p>
</o:p>
</span></font></p>
</td>
</tr>
<tr>
<td width="277" valign="top" style="width:207.75pt;border-top:none;border-left:
none;border-bottom:solid windowtext .5pt;border-right:solid windowtext .5pt;
mso-border-top-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt">
<p class="MsoHeading9" style="margin-top: 0"><span lang="EN-US"><font size="2">WM_RBUTTONUP<o:p>
</o:p>
</font></span></p>
</td>
<td width="298" valign="top" style="width:223.65pt;border:none;border-bottom:
solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:
solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt">
<p class="MsoHeading9" style="margin-top: 0"><span style="font-family:宋体;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman""><font size="2">放开鼠标右键时产生的消息</font></span><font size="2"><span lang="EN-US"><o:p>
</o:p>
</span></font></p>
</td>
</tr>
<tr>
<td width="277" valign="top" style="width:207.75pt;border-top:none;border-left:
none;border-bottom:solid windowtext .5pt;border-right:solid windowtext .5pt;
mso-border-top-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt">
<p class="MsoHeading9" style="margin-top: 0"><span lang="EN-US"><font size="2">WM_LBUTTONDBCLK<o:p>
</o:p>
</font></span></p>
</td>
<td width="298" valign="top" style="width:223.65pt;border:none;border-bottom:
solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:
solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt">
<p class="MsoHeading9" style="margin-top: 0"><span style="font-family:宋体;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman""><font size="2">双击鼠标左键时产生的消息</font></span><font size="2"><span lang="EN-US"><o:p>
</o:p>
</span></font></p>
</td>
</tr>
<tr>
<td width="277" valign="top" style="width:207.75pt;border-top:none;border-left:
none;border-bottom:solid windowtext .5pt;border-right:solid windowtext .5pt;
mso-border-top-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt">
<p class="MsoHeading9" style="margin-top: 0"><span lang="EN-US"><font size="2">WM_RBUTTONDBCLK<o:p>
</o:p>
</font></span></p>
</td>
<td width="298" valign="top" style="width:223.65pt;border:none;border-bottom:
solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:
solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt">
<p class="MsoHeading9" style="margin-top: 0"><span style="font-family:宋体;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman""><font size="2">双击鼠标右键时产生的消息</font></span><font size="2"><span lang="EN-US"><o:p>
</o:p>
</span></font></p>
</td>
</tr>
</table>
<p ALIGN="left" 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 FACE="oúì?,SimHei" LANG="ZH-CN" size="2">2.
键盘消息</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">(1)
WM_KEYDOWN</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2"><font FACE="??ì?,SimSun" LANG="ZH-CN">这是在按下一个非系统键时产生的消息。此外相似的消息还有</font>WM_KEYUP<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">(2)
WM_CHAR</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font FACE="??ì?,SimSun" LANG="ZH-CN" size="2">这也是按下一个非系统键时产生的消息。</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 FACE="oúì?,SimHei" LANG="ZH-CN" size="2">3.
关闭窗口消息</font></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>WM_CLOSE<font FACE="??ì?,SimSun" 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 FACE="oúì?,SimHei" LANG="ZH-CN" size="2">4.
退出程序消息</font></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>WM_QUIT<font FACE="??ì?,SimSun" LANG="ZH-CN">,这是退出应用程序时由</font>PostQuitMessage<font FACE="??ì?,SimSun" 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 FACE="oúì?,SimHei" LANG="ZH-CN" size="2">5.
重画消息 </font><font color="#FF9933" FACE="??ì?,SimSun" LANG="ZH-CN" size="2"><b>这是一个十分重要的消息</b></font></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>WM_PAINT<font FACE="??ì?,SimSun" LANG="ZH-CN">消息。此外,当下拉式菜单关闭并需要恢复被覆盖的部分以及</font>Windows<font FACE="??ì?,SimSun" LANG="ZH-CN">清除对话框或消息框等对象,并需要恢复被覆盖的部分时,将产生</font>WM_PAINT<font FACE="??ì?,SimSun" LANG="ZH-CN">消息。</font></font></p>
<p style="line-height: 150%; text-indent: 0; margin: 0" align="left" class="右标题"> </p>
<hr size="1" color="#008000">
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> <span style="position: absolute; left: 33; top: 577"><a href="right9-2.htm" target="_self"><img border="0" src="rightd1.gif" width="113" height="70"></a></span>
<span style="position: absolute; left: 488; top: 577"><a href="right9-4.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 + -