⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 right11-2.htm

📁 Visual C++面向对象程序设计教程(配套习题资源)
💻 HTM
📖 第 1 页 / 共 2 页
字号:
</font></p>
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">BOOL InsertMenu(HMENU hMenu,UINT uPosition,UINT uFlags,UINT     
  uIDNewltem,LPCTSTR lpNewltem);</font></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>
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">BOOL DeleteMenu<font FACE="??ì?,SimSun" LANG="ZH-CN" SIZE="1">(</font>HMENU     
  hMenu<font FACE="??ì?,SimSun" LANG="ZH-CN" SIZE="1">,</font>UINT     
  uPosition<font FACE="??ì?,SimSun" LANG="ZH-CN" SIZE="1">,</font>UINT     
  uFlags<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">
(5) 修改菜单项    
</font></p>
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">BOOL ModifyMenu(HMENU hMnu,UINT uPosition,UINT uFlags,UINT     
  uIDNewltem,LPCTSTR lpNewltem);</font></p>    
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font FACE="oúì?,SimHei" LANG="ZH-CN" size="2">
(6) 禁止或激活菜单项    
</font></p>
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">BOOL EnableMenuItem(HMENU hMenu<font FACE="??ì?,SimSun" LANG="ZH-CN" SIZE="1">,</font>UINT     
  uIDEnableItem<font FACE="??ì?,SimSun" LANG="ZH-CN" SIZE="1">,</font>UINT     
  uEnable);</font></p>
</blockquote>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">3. 
</font> <font FACE="??ì?,SimSun" LANG="ZH-CN"><font size="2">菜单的消息处理</font></p>
</font><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_COMMAND<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">switch (iMsg)</font></p>    
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">{</font></p>
  <blockquote>
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">case WM_COMMAND :</font></p> 
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">switch (LOWORD (wParam))</font></p> 
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">{</font></p>
    <blockquote>
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">case IDM_NEW :</font></p> 
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">case IDM_OPEN :</font></p> 
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">case IDM_SAVE :</font></p> 
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">case IDM_SAVEAS :</font></p> 
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">MessageBeep (0) ;</font></p> 
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">return 0 ;</font></p> 
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">case IDM_EXIT :</font></p> 
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">SendMessage (hwnd, WM_CLOSE, 0, 0L) ;</font></p> 
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">return 0 ;</font></p> 
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">case WM_TIMER :</font></p> 
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">MessageBeep (0) ;</font></p> 
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">return 0 ;</font></p> 
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">case WM_DESTROY :</font></p> 
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">PostQuitMessage (0) ;</font></p> 
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">return 0 ;</font></p> 
    </blockquote>
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">}</font></p>
  </blockquote>
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">}</font></p>
</blockquote>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">4. 
</font> <font FACE="??ì?,SimSun" LANG="ZH-CN"><font size="2">加速键</font></p>
<font SIZE="3">
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font FACE="??ì?,SimSun" LANG="ZH-CN" size="2">通过资源管理器,用户可以添加和编辑加速键资源,创建方法和其他资源相同。加速键创建成功后,会在资源描述文件中出现类似于以下的代码:
  </font></p>
<blockquote>
</font>
</blockquote>
<blockquote>
  <blockquote>
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">ACCELERATOR ACCELERATORS DISCARDABLE</font></p>    
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">BEGIN</font></p>
  <blockquote>
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">&quot;C&quot;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IDM_COPY,&nbsp;&nbsp;&nbsp;&nbsp; VIRTKEY, CONTROL, NOINVERT</font></p>    
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">&quot;N&quot;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IDM_NEW,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VIRTKEY, CONTROL, NOINVERT</font></p>    
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">&quot;O&quot;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IDM_OPEN,&nbsp;&nbsp;&nbsp;&nbsp; VIRTKEY, CONTROL, NOINVERT</font></p>    
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">&quot;S&quot;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IDM_SAVE,&nbsp;&nbsp;&nbsp;&nbsp; VIRTKEY, CONTROL, NOINVERT</font></p>    
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">&quot;T&quot;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IDM_START,&nbsp;&nbsp;&nbsp; VIRTKEY, CONTROL, NOINVERT</font></p>    
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">&quot;V&quot;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IDM_PASTE,&nbsp;&nbsp;&nbsp; VIRTKEY, CONTROL, NOINVERT</font></p>    
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">VK_DELETE,&nbsp; IDM_DEL,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VIRTKEY, NOINVERT</font></p>    
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">VK_F1,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IDM_HELP,&nbsp;&nbsp;&nbsp;&nbsp; VIRTKEY, NOINVERT</font></p>    
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">VK_PAUSE,&nbsp;&nbsp; IDM_STOP,&nbsp;&nbsp;&nbsp;&nbsp; VIRTKEY, NOINVERT</font></p>    
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">&quot;X&quot;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IDM_CUT,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VIRTKEY, CONTROL, NOINVERT</font></p>    
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">&quot;Z&quot;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IDM_UNDO,&nbsp;&nbsp;&nbsp;&nbsp; VIRTKEY, CONTROL, NOINVERT</font></p>    
  </blockquote>
  <p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font color="#008000" size="2">END</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>ACCELERATOR<font FACE="??ì?,SimSun" LANG="ZH-CN">的加速键表,包括</font>11<font FACE="??ì?,SimSun" LANG="ZH-CN">个加速键。</font>VK_F1<font FACE="??ì?,SimSun" LANG="ZH-CN">为键盘上的〈</font>F1<font FACE="??ì?,SimSun" LANG="ZH-CN">〉键,它对应的菜单项的</font>ID<font FACE="??ì?,SimSun" LANG="ZH-CN">为</font>IDM_HELP<font FACE="??ì?,SimSun" LANG="ZH-CN">;“</font>C<font FACE="??ì?,SimSun" LANG="ZH-CN">”是虚拟键的加速键,它带有</font>Ctrl<font FACE="??ì?,SimSun" LANG="ZH-CN">修饰键,表示加速键为〈</font>Ctrl<font FACE="??ì?,SimSun" LANG="ZH-CN">〉</font>+<font FACE="??ì?,SimSun" LANG="ZH-CN">〈</font>C<font FACE="??ì?,SimSun" LANG="ZH-CN">〉,它对应菜单项的</font>ID<font FACE="??ì?,SimSun" LANG="ZH-CN">为</font>IDM_COPY<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="??ì?,SimSun" lang="ZH-CN" size="2">5.综合举例</font></p>
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font FACE="??ì?,SimSun" LANG="ZH-CN" size="2"><span style="font-size:10.0pt;font-family:宋体;
mso-ascii-font-family:&quot;Times New Roman&quot;;mso-hansi-font-family:&quot;Times New Roman&quot;;
mso-bidi-font-family:&quot;Times New Roman&quot;;mso-font-kerning:10.5pt;mso-ansi-language:
EN-US;mso-fareast-language:ZH-CN;mso-bidi-language:AR-SA"><a href="example11-2.htm" target="_blank">【例</a></span><a href="example11-2.htm" target="_blank"><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Times New Roman&quot;;mso-fareast-font-family:
宋体;mso-font-kerning:10.5pt;mso-ansi-language:EN-US;mso-fareast-language:ZH-CN;
mso-bidi-language:AR-SA">11-2</span><span style="font-size:10.0pt;font-family:
宋体;mso-ascii-font-family:&quot;Times New Roman&quot;;mso-hansi-font-family:&quot;Times New Roman&quot;;
mso-bidi-font-family:&quot;Times New Roman&quot;;mso-font-kerning:10.5pt;mso-ansi-language:
EN-US;mso-fareast-language:ZH-CN;mso-bidi-language:AR-SA">】</span></a>使用菜单改变背景颜色,并可以定时发送消息。</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">&nbsp;&nbsp; <span style="position: absolute; left: 32; top: 1948"><a href="right11-1.htm" target="_self"><img border="0" src="rightd1.gif" width="113" height="70"></a></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                             
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="position: absolute; left: 506; top: 1950"><a href="right11-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 + -