📄 c++ builder 初学问与答 (十).htm
字号:
</tr>
</table>
</td>
<td width="588" align="right" class="tableright">
<table width="575" border="0" cellpadding="0" cellspacing="0" style="table-layout:fixed;word-break:break-all">
<tr>
<td align="center" height=32 style="font-size: 12pt;color: #FF6600;">C++ Builder 初学问与答 (十)</td>
</tr>
<tr>
<td align="center" height=25 bgcolor=#F7F7F7>作者:佚名 来源:不详 发布时间:25/09/2006 19:29:54 发布人:admin</td>
</tr>
<script language=javascript>
var newasp_fontsize=9;
var newasp_lineheight=12;
</script>
<tr>
<td><p align="right"><a style="CURSOR: hand; POSITION: relative" onclick="if(newasp_fontsize>8){NewaspContentLabel.style.fontSize=(--newasp_fontsize)+"pt";NewaspContentLabel.style.lineHeight=(--newasp_lineheight)+"pt";}" title="减小字体"><img src="/images/1.gif" border="0" width="15" height="15"><font color="#FF6600">减小字体</font></a>
<a style="CURSOR: hand; POSITION: relative" onclick="if(newasp_fontsize<64){NewaspContentLabel.style.fontSize=(++newasp_fontsize)+"pt";NewaspContentLabel.style.lineHeight=(++newasp_lineheight)+"pt";}" title="增大字体"><img src="/images/2.gif" border="0" width="15" height="15"><font color="#FF6600">增大字体</font></a>
</p>
<div id="NewaspContentLabel" style="display:block;padding:0px 10px;" class="ContentFont"><FONT id=font_word style="FONT-SIZE: 14px; FONT-FAMILY: 宋体, Verdana, Arial, Helvetica, sans-serif"><H3 style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><A name=_Toc494087979></A><A name=_Toc494088151><SPAN style="mso-bookmark: _Toc494087979"><SPAN lang=EN-US><FONT face=宋体 size=3>10.菜单组件</FONT></SPAN></SPAN></A></H3><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><B><SPAN lang=EN-US>77</SPAN></B><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">)问:</SPAN></B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">菜单是</SPAN><SPAN lang=EN-US><a target="_blank" href="http://www.malegebide.com" class="wordstyle">Windows</a></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">常用的用户界面。对于一个能够实际应用的程序,菜单是必不可少的组成部分。</SPAN><SPAN lang=EN-US>C++Builder</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">中是怎样实现菜单的?</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: center; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt" align=center><B><SPAN lang=EN-US><FONT size=3> <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT></SPAN></B></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">答:</SPAN></B><SPAN lang=EN-US>C++Builder</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">为我们提供了两种菜单组件:一种是主菜单组件</SPAN><SPAN lang=EN-US>MainMenu</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">;另一种是弹出菜单</SPAN><SPAN lang=EN-US>PopMenu</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">组件。</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''"><FONT size=3>主菜单组件的作用是在窗体上生成菜单条。菜单组件刚放到窗体上时,菜单是不可见的,当双击它打开菜单编辑器并且增加了菜单项后,菜单条才出现在窗体的顶部。设计时的菜单条与运行时的菜单条完全一样。</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''"><FONT size=3>下面我们介绍利用菜单编辑器进行菜单设计的过程。</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><B><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">首先要打开菜单编辑器</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></B></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">从组件模板上的</SPAN><SPAN lang=EN-US>Standard</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">选项卡中选择</SPAN><SPAN lang=EN-US>MainMenu</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">组件,<font id="wcvgostvwwpw">xjNMM-Nz2\U&</font><span id="nstbawgwqsqacaguvaj">育n,络网h!XHeBsm$P网pze</span>放置到窗体上。然后,用鼠标右键单击菜单组件,然后在弹出菜单中选择</SPAN><SPAN lang=EN-US>Menu Designer</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">。当然,你也可以双击菜单组件打开菜单编辑器。</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''"><FONT size=3>被加亮显示的小方框就是一个空白菜单项。</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><B><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">接着要添加菜单项</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></B></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''"><FONT size=3>选中这个菜单项,<span id="abephinavd">`#:CE专Uv教l</span>这时对象编辑器中将出现这个菜单项的属性。</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">我们在菜单项的</SPAN><SPAN lang=EN-US>Caption</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">属性中输入“文件(</SPAN><SPAN lang=EN-US>&File</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">)”,其中“</SPAN><SPAN lang=EN-US>&F</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">”可以生成一个快捷键,这样用户就可以通过键盘操作了,并且</SPAN><SPAN lang=EN-US>F</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">下面出现了下划线(注意:由于是系统原因,</SPAN><SPAN lang=EN-US>”&”</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">一定要在英文状态下输入)。当我们输入完标题并按下回车键时,</SPAN><SPAN lang=EN-US>C++Buildr</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">会自动给这个菜单项赋一个名字,这里的名字是</SPAN><SPAN lang=EN-US>N1</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">。如果你不满意这个名字可以修改</SPAN><SPAN lang=EN-US>Name</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">属性。</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''"><FONT size=3>添加完菜单项后会自动出现一个空白的子菜单项等待你输入。</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">现在菜单编辑器中的输入焦点移到了这个空白子菜单项上,同时对象编辑器将对应显示这个子菜单项的属性。你可以在</SPAN><SPAN lang=EN-US>Caption</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">属性中输入子菜单项的标题“打开(</SPAN><SPAN lang=EN-US>&Open</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">)”,然后按下回车键。菜单编辑器会打开一个新的子菜单项,并把输入焦点移动到这个子菜单项上。这样,就可以给菜单项增加一系列的子菜单了。</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''"><FONT size=3>同样方法添加退出菜单。</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: center; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt" align=center><SPAN lang=EN-US style="mso-font-kerning: 0pt"><?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /><v:shapetype id=_x0000_t75 stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><v:path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"></v:path><o:lock aspectratio="t" v:ext="edit"></o:lock></v:shapetype><v:shape id=_x0000_i1025 style="WIDTH: 369pt; HEIGHT: 274.5pt" type="#_x0000_t75"><img o:title="菜单" src="http://www.tongyi.net:80/Develop/ArticleImages/20/20638/CSDN_Dev_Image_2003-8-241904310.png" onload="return imgzoom(this,550)"><FONT size=3></FONT></v:shape><o:p></o:p></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: center; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt" align=center><SPAN lang=EN-US><FONT size=3> <o:p></o:p></FONT></SPAN></P><P class=MsoBodyTextIndent2 style="MARGIN: 0cm 0cm 0pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''"><FONT size=3>要开始编辑下一个菜单项,可以用鼠标单击菜单项“文件”的右边的虚线框,它表示一个空白的菜单项。</FONT></SPAN></P><P class=MsoBodyText style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN lang=EN-US style="COLOR: windowtext"><FONT size=3> <o:p></o:p></FONT></SPAN></P><P class=MsoBodyText style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><B><SPAN lang=EN-US style="COLOR: windowtext">78</SPAN></B><B><SPAN style="COLOR: windowtext; FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">)问:</SPAN></B><SPAN style="COLOR: windowtext; FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">当菜单项中的子菜单项属于不同类别时,有必要用分隔条把子菜单项进行分组,菜单组件是怎样实现这个功能的?</SPAN><SPAN lang=EN-US style="COLOR: windowtext"><o:p></o:p></SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">答:</SPAN></B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">我们在退出和保存两个菜单项中间加入选择分隔条,在退出菜单项上点击鼠标右键,从弹出菜单中选择</SPAN><SPAN lang=EN-US>Insert</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">,这时,一个空白的菜单项就插入了,将它的</SPAN><SPAN lang=EN-US>Caption</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">属性设置为“</SPAN><SPAN lang=EN-US>–</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">”这个减号符就可以了。</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN lang=EN-US><FONT size=3> <o:p></o:p></FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><B><SPAN lang=EN-US>79</SPAN></B><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">)问:</SPAN></B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">那么,我们又怎样给菜单项设置热键呢?</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">答:</SPAN></B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">每个菜单项都有一个属性</SPAN><SPAN lang=EN-US>ShortCut</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">,利用这个属性就可以给这个菜单项设置热键了。现在我们给打开文件菜单项添加热键。单击这个菜单项,选择属性</SPAN><SPAN lang=EN-US>ShortCut</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">,出现一个下拉菜单,其中包括一系列的热键的组合。选择</SPAN><SPAN lang=EN-US>Ctrl+O</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">,这个热键中就被赋给了退出菜单项。</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><B><SPAN lang=EN-US><FONT size=3> <o:p></o:p></FONT></SPAN></B></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><B><SPAN lang=EN-US>80</SPAN></B><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">)问:</SPAN></B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">快捷键与热键这两个概念我已经弄糊涂了,<p id="dsvbeqhnwthse">BF\B{I;gjU教k理</p>您能给我解释一下吗?</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">答:</SPAN></B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">好的,快捷键与热键相同的方面是,它们都是通过键盘来访问。</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">一个菜单项可以同时拥有快捷键和热键。所谓快捷键通常只是一个字母,而热键通常是一个组合键。另外它们的激活方式不一样,例如一个子菜单项有一个快捷键</SPAN><SPAN lang=EN-US>O</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">和一个热键</SPAN><SPAN lang=EN-US>Ctrl+O</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">,那么使用热键就可以直接激活这个子菜单项,而使用快捷键你必须首先选中该子菜单项上一层的菜单项,然后按下快捷键才可以激活这个子菜单项。</SPAN></FONT></P><P class=MsoBodyText style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN lang=EN-US style="COLOR: windowtext"><FONT size=3> <o:p></o:p></FONT></SPAN></P><P class=MsoBodyText style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><B><SPAN lang=EN-US style="COLOR: windowtext">81</SPAN></B><B><SPAN style="COLOR: windowtext; FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">)问:</SPAN></B><SPAN style="COLOR: windowtext; FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">您讲解的菜单到现在还只有菜单项和子菜单两级,如果我希望子菜单还有自己的子菜单,应该怎么办?</SPAN><SPAN lang=EN-US style="COLOR: windowtext"><o:p></o:p></SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">答:</SPAN></B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">这种嵌套的菜单项实际上就是级联菜单。这里,我们给颜色菜单项添加子菜单项,选择颜色菜单,单击鼠标右键,在弹出的快捷菜单中选择</SPAN><SPAN lang=EN-US>Create Submenu</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">命令,这时在子菜单项中将出现一个指向右的箭头,同时还产生了一个级联菜单。</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">当然,你也可以用</SPAN><SPAN lang=EN-US>Ctrl+</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">方向键右键。</SPAN></FONT></P><P class=MsoBodyText style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN lang=EN-US style="COLOR: windowtext"><FONT size=3> <o:p></o:p></FONT></SPAN></P><P class=MsoBodyText style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><B><SPAN lang=EN-US style="COLOR: windowtext">82</SPAN></B><B><SPAN style="COLOR: windowtext; FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">)问:</SPAN></B><SPAN style="COLOR: windowtext; FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">很多菜单项的旁边有复选标记,请问菜单编辑器是否提供了这个功能呢?</SPAN><SPAN lang=EN-US style="COLOR: windowtext"><o:p></o:p></SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">答:</SPAN></B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">复选标记就是在菜单项的标题的前面出现的勾号。复选标记经常用于一些状态设置的菜单项,当处于该状态时就会出现复选标记,否则复选标记消失。</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">现在,我们给回绕菜单项设置复选标记,在对象编辑器中把它的属性</SPAN><SPAN lang=EN-US>Checked</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">改为</SPAN><SPAN lang=EN-US>True</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">,这样这个菜单项就会显示复选标记。要取消复选标记可以把</SPAN><SPAN lang=EN-US>Checked</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">属性再次设置为</SPAN><SPAN lang=EN-US>False</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">。</SPAN></FONT></P><P class=MsoBodyText style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><B><SPAN lang=EN-US style="COLOR: windowtext"><FONT size=3> <o:p></o:p></FONT></SPAN></B></P><P class=MsoBodyText style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><B><SPAN lang=EN-US style="COLOR: windowtext">83</SPAN></B><B><SPAN style="COLOR: windowtext; FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">)问:</SPAN></B><SPAN style="COLOR: windowtext; FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">我有时要设计一组互相排斥的菜单项,<font id="oprpnmqjphqetbv">Cfry{fHEi9提8u*V</font>也就是单选菜单项,应该怎么办呢?</SPAN><SPAN lang=EN-US style="COLOR: windowtext"><o:p></o:p></SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">答:</SPAN></B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">要使一组菜单项成为单选菜单项,必须满足几个条件。</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''"><FONT size=3>首先,<div id="facvfmfhrmjbd">_k育B*教{中%B*d无</div>这一组菜单必须在同一个下拉菜单中。</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">其次,它们的</SPAN><SPAN lang=EN-US>RadioItem</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">属性必须都设置成了</SPAN><SPAN lang=EN-US>True</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">。</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 23.5pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">最后,它们的</SPAN><SPAN lang=EN-US>GroupIndex</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">属性必须相同。</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 23.5pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''"><FONT size=3>这一组中唯一被选中的菜单项的前面将会显示一个圆点标记。</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN lang=EN-US><FONT size=3> <o:p></o:p></FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><B><SPAN lang=EN-US>84</SPAN></B><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">)问:</SPAN></B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">我怎样使菜单项失效呢?</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">答:</SPAN></B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">只要把菜单项的</SPAN><SPAN lang=EN-US>Enabled</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">属性设置为</SPAN><SPAN lang=EN-US>False</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">,<div id="ctcbwclgwikkhbt">!D5m网业'"z5lb-网!</div>就可以使菜单项失效,这时菜单项是灰色的。在设计时和运行时你可以任意设置菜单项的</SPAN><SPAN lang=EN-US>Enabled</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">属性。</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><B><SPAN lang=EN-US><FONT size=3> <o:p></o:p></FONT></SPAN></B></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><B><SPAN lang=EN-US>85</SPAN></B><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">)问:</SPAN></B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">菜单项有些什么常用的事件呢?</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">答:</SPAN></B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">菜单项只有一种事件</SPAN><SPAN lang=EN-US>OnClick</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">,在实际编辑中这个事件是一定要响应的。</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN lang=EN-US><FONT size=3> <o:p></o:p></FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT size=3><B><SPAN lang=EN-US>86</SPAN></B><B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">)问:</SPAN></B><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">我们一般在主菜单之外还会提供一个快捷菜单,就像</SPAN><SPAN lang=EN-US>C++Builder</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">一样,在窗体中单击右键随时都可以打开一个弹出菜单。</SPAN><SPAN lang=EN-US>C++Builder</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">是怎样实现弹出菜单的?</SPAN></FONT></P><B><SPAN style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''; mso-bidi-font-size: 10.0pt; mso-font-kerning: 1.0pt; mso-bidi-language: HE; mso-bidi-font-family: ''''Times New Roman''''; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN"> 答:</SPAN></B><SPAN style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''; mso-bidi-font-size: 10.0pt; mso-font-kerning: 1.0pt; mso-bidi-language: HE; mso-bidi-font-family: ''''Times New Roman''''; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN">弹出菜单有时候又称为快捷菜单。弹出菜单与主菜单的区别是:主菜单是固定的,而弹出菜单是活动的;主菜单有多组菜单项,而弹出菜单只有一组。弹出菜单的设计方法与主菜单基本相同,也是使用菜单编辑器来完成的。</SPAN></span></span> <div id="Message" class="Message"></div></font></div>
<div></div>
</td>
</tr>
<tr>
<td align="right" height=25 bgcolor=#F7F7F7 style="display:block;padding:0px 10px">
[<script language=JavaScript src="/article/Hits.Asp?ArticleID=18323"></script>]
[<a href="javascript:history.go(-1)">返回上一页</a>]
[<a href=javascript:window.print()>打 印</a>]
[<a href="/user/favorite.asp?action=add&topic=C++ Builder 初学问与答 (十)">收 藏</a>]</td>
</tr>
<tr>
<td style="display:block;padding:0px 10px"><div>上一篇文章:<a href=/article/1/14/2006/2006092518322.html>对比C++和Java</a></div><div>下一篇文章:<a href=/article/1/14/2006/2006092518324.html>C++对象模型之七 模板 异常 RTTI笔记</a></div></td>
</tr>
</table>
<table width="575" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="titlebg1">∷相关文章评论∷ (评论内容只代表网友观点,与本站立场无关!) [<a href=/article/comment.asp?ArticleID=18323 target=_blank>更多评论</a>…]</td>
</tr>
<tr valign="top">
<td></td>
</tr>
</table>
</td>
</tr>
</table>
<!-- 页面底部开始 -->
<table width="778" border="0" align="center" cellpadding="0" cellspacing="0" class="tableborder">
<tr>
<td height="5"></td>
</tr>
<tr>
<td height="8" class="linebar"></td>
</tr>
<tr>
<td height="5"></td>
</tr>
<tr>
<td height="65" align="center" class="tablebody">QQ:310646
<a href="/admin/admin_login.asp" target="_blank" class="navmenu">A</a>
Copyright © 2006 <font face=Verdana, Arial, Helvetica, sans-serif><b>Malegebide.Com</b></font>. <script language="javascript" type="text/javascript" src="http://js.users.51.la/529370.js"></script>No Rights Reserved <br></td>
</tr>
<tr>
<td height="5"></td>
</tr>
</table>
</body>
</html>
<script language="javascript" src="/inc/Std_StranJF.Js"></script>
<!-- 页面底部结束 -->
<script src="/count.asp" type="text/javascript"></script>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -