?? c++ builder 初學問與答(二).htm
字號:
· <a href=/article/5/11/2006/200608301360.html title='Google排名—搜索引擎登記技巧'>Google排名—搜索引..</a><br>
· <font color='#0066FF'>[圖文]</font> <a href=/article/10/2006/200608291188.html title='菜鳥安全防患之餓死木馬'>菜鳥安全防患..</a><br>
· <a href=/article/9/2006/20060827361.html title='數學最大數字'>數學最大數字</a><br>
· <a href=/article/10/2006/200608291195.html title='Google搜索技巧(6):用Google找自己'>Google搜索技巧(6):..</a><br></td>
</tr>
<tr>
<td height="2" bgcolor="#FFFFFF"></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="titleback1">相關文章</td>
</tr>
<tr>
<td height="100" valign="top">· <a href="/article/1/14/2006/2006092518481.html" title='《c++ primer》讀書筆記4'>《c++ primer》讀書..</a><br>
· <a href="/article/1/14/2006/2006092518480.html" title='《c++ primer》讀書筆記6'>《c++ primer》讀書..</a><br>
· <a href="/article/1/14/2006/2006092518477.html" title='一個有意思的C++ trick (2)'>一個有意思的C++ tr..</a><br>
· <a href="/article/1/14/2006/2006092518473.html" title='《c++ primer》讀書筆記3'>《c++ primer》讀書..</a><br>
· <a href="/article/1/14/2006/2006092518472.html" title='《c++ primer》讀書筆記5'>《c++ primer》讀書..</a><br>
· <a href="/article/1/14/2006/2006092518470.html" title='如何在C++ Builder的DLL中使用數據庫控件'>如何在C++ Builder的..</a><br>
· <a href="/article/1/14/2006/2006092518469.html" title='Python 與 C++ 程序的簡單實例對比'>Python 與 C++ 程序..</a><br>
· <a href="/article/1/14/2006/2006092518468.html" title='Visual C++ MFC 一文說盡 (推薦)(很長,沒耐心就不要看了)'>Visual C++ MFC 一文..</a><br>
· <a href="/article/1/14/2006/2006092518466.html" title='VC++ Members Weblog'>VC++ Members Weblo..</a><br>
· <a href="/article/1/14/2006/2006092518459.html" title='C++ Builder和托管C++中屬性的使用建議'>C++ Builder和托管C..</a><br></td>
</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:25:18 發布人: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: 24pt; mso-char-indent-count: 2.0; mso-char-indent-size: 12.0pt"><A name=_Toc494087971></A><A name=_Toc494088143><SPAN style="mso-bookmark: _Toc494087971"><SPAN lang=EN-US style="COLOR: windowtext"><FONT face=Arial size=3>2.</FONT></SPAN></SPAN></A><FONT size=3><SPAN style="mso-bookmark: _Toc494088143"><SPAN style="mso-bookmark: _Toc494087971"><SPAN style="COLOR: windowtext; FONT-FAMILY: 黑體; mso-ascii-font-family: Arial">文本輸入組件</SPAN></SPAN></SPAN><SPAN style="mso-bookmark: _Toc494087971"></SPAN><SPAN style="mso-bookmark: _Toc494088143"></SPAN><SPAN lang=EN-US style="COLOR: windowtext"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></FONT></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>11</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></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 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>Edit</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">、</SPAN><SPAN lang=EN-US>MaskEdit </SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">、</SPAN><SPAN lang=EN-US>Memo</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">和</SPAN><SPAN lang=EN-US>RichEdit</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">。他們的主要不同在于</SPAN><SPAN lang=EN-US>Edit</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">和</SPAN><SPAN lang=EN-US>MaskEdit</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">用于輸入單行文本,而</SPAN><SPAN lang=EN-US>Memo</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">和</SPAN><SPAN lang=EN-US>RichEdit</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">可以輸入多行文本。此外</SPAN><SPAN lang=EN-US>Label</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 lang=EN-US>Edit</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">和</SPAN><SPAN lang=EN-US>MaskEdit</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><SPAN lang=EN-US><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>12</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>(Edit)</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><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 lang=EN-US>Text</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">屬性是一個</SPAN><SPAN lang=EN-US>String</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">類型的數據,<span id="jpudcrnjurtemvc">i?xI`c8f@}V國]48</span>它決定了在編輯框中出現的文本字符串。在編程中,我們經常要通過</SPAN><SPAN lang=EN-US>text</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 lang=EN-US>MaxLength</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">是一個</SPAN><SPAN lang=EN-US>Integer</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">類型的數據,它指定編輯框所能容納的最大字符數。缺省情況下為</SPAN><SPAN lang=EN-US>0</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 lang=EN-US><SPAN style="mso-spacerun: yes"> </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">編輯框還可以用做口令輸入。具體方法是,把</SPAN><SPAN lang=EN-US>PasswordChar</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">屬性設置為除</SPAN><SPAN lang=EN-US>#0</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">之外的任何字符。這時,無論你在編輯框中輸入什么字符,都只顯示</SPAN><SPAN lang=EN-US>PasswordChar</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">包含的字符。我們經常把</SPAN><SPAN lang=EN-US>PasswordChar</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>#0</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">表示編輯框正常顯示。</SPAN><SPAN lang=EN-US>PasswordChar</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''''">如果要限制用戶對編輯框寫的權利??梢允褂脤傩?lt;/SPAN><SPAN lang=EN-US>ReadOnly</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">,當</SPAN><SPAN lang=EN-US>ReadOnly</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: 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>13</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>(Label)</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><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>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>FocusControl</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 lang=EN-US>Caption</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 lang=EN-US>FocusControl</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>Caption</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>14</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>Label</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>FocusControl</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><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''''">下面舉個例子說吧(這個例子在第19問中會用到):</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>&</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>&N</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">姓名,這里字母</SPAN><SPAN lang=EN-US>N</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">就被指定為快捷鍵,要注意的是中文是不能被指定為快捷鍵的,只有</SPAN><SPAN lang=EN-US>26</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>FocusControl</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">屬性與編輯框</SPAN><SPAN lang=EN-US>Edit1</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">相連,選擇</SPAN><SPAN lang=EN-US>FocusControl</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">屬性,從屬性值字段列舉的窗體上所有的窗口控件中選取</SPAN><SPAN lang=EN-US>Edit1</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">。這樣當用戶按下</SPAN><SPAN lang=EN-US>Alt+N</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">時,輸入焦點就會轉移到編輯框</SPAN><SPAN lang=EN-US>Edit1</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>15</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></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>OnKeyPress</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">事件。所以如果要在程序中處理這種事件,這就要編寫</SPAN><SPAN lang=EN-US>OnKeyPress</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>OnChange</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">事件、</SPAN><SPAN lang=EN-US>OnEnter</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">事件和</SPAN><SPAN lang=EN-US>OnExit</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">事。每當編輯框中的文本發生改變時都會觸發</SPAN><SPAN lang=EN-US>OnChange</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">事件。當編輯框獲得輸入焦點時會觸發</SPAN><SPAN lang=EN-US>OnEnter</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">事件,而失去焦點時會產生</SPAN><SPAN lang=EN-US>OnExit</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>16</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>Memo</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 22.65pt"><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>Memo</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">與</SPAN><SPAN lang=EN-US>Edit</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">的屬性有很多相似的,下面只來說一下</SPAN><SPAN lang=EN-US>Memo</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 lang=EN-US>Lines</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">屬性是一個</SPAN><SPAN lang=EN-US>TStrings</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">類的一個對象,它是由多個字符串組成的,每一個字符串就是</SPAN><SPAN lang=EN-US>Lines</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">中的一個元素。</SPAN><SPAN lang=EN-US>Memo</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">組件的每一行文本都是</SPAN><SPAN lang=EN-US>Lines</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"><FONT size=3><SPAN lang=EN-US><SPAN style="mso-tab-count: 1"> </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">在設計階段,如果要給</SPAN><SPAN lang=EN-US>Memo</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">組件增加一些顯示內容,可以在對象編輯器中選擇屬性</SPAN><SPAN lang=EN-US>Lines</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">,單擊</SPAN><SPAN lang=EN-US>Value</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"><FONT size=3><SPAN lang=EN-US><SPAN style="mso-tab-count: 1"> </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">在這個編輯器中輸入文本。編輯器中顯示的所有內容都會出現在</SPAN><SPAN lang=EN-US>Memo</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 lang=EN-US>Memo</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">組件屬性中:</SPAN></FONT></P><TABLE style="MARGIN-LEFT: 5.4pt; BORDER-COLLAPSE: collapse; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt" cellSpacing=0 cellPadding=0 border=0><TR><TD style="BORDER-RIGHT: #ece9d8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 90.8pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" vAlign=top width=121><P class=MsoToc1 style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN lang=EN-US>Alignment</SPAN></P></TD><TD style="BORDER-RIGHT: #ece9d8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 272.4pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" vAlign=top width=363><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''''">用來確定</SPAN><SPAN lang=EN-US>Memo</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">組件中顯示文本的對齊方式。</SPAN></P></TD></TR><TR><TD style="BORDER-RIGHT: #ece9d8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 90.8pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" vAlign=top width=121><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>WordWrap</SPAN></P></TD><TD style="BORDER-RIGHT: #ece9d8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 272.4pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" vAlign=top width=363><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''''">確定文本到達右邊界時是否自動換行</SPAN></P></TD></TR><TR><TD style="BORDER-RIGHT: #ece9d8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 90.8pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" vAlign=top width=121><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>WantReturn</SPAN></P></TD><TD style="BORDER-RIGHT: #ece9d8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 272.4pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" vAlign=top width=363><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''''">確定用戶是否可以在文本中插入回車符。</SPAN></P></TD></TR><TR><TD style="BORDER-RIGHT: #ece9d8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 90.8pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" vAlign=top width=121><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>WantTabs</SPAN></P></TD><TD style="BORDER-RIGHT: #ece9d8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 272.4pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" vAlign=top width=363><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''''">確定用戶是否可以在文本中插入</SPAN><SPAN lang=EN-US>Tab</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">字符。</SPAN></P></TD></TR></TABLE><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>ScrollBar</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">是一個常見的屬性,它確定著滾動組件滾動條的行為。</SPAN><SPAN lang=EN-US>ScrollBar</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">有四種可能的取值:</SPAN></FONT></P><TABLE style="MARGIN-LEFT: 7.05pt; BORDER-COLLAPSE: collapse; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt" cellSpacing=0 cellPadding=0 border=0><TR><TD style="BORDER-RIGHT: #ece9d8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 89.15pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" vAlign=top width=119><P class=MsoToc1 style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN lang=EN-US>SsNone</SPAN></P></TD><TD style="BORDER-RIGHT: #ece9d8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 238.35pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" vAlign=top width=318><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''''">表示沒有滾動條;</SPAN></P></TD></TR><TR><TD style="BORDER-RIGHT: #ece9d8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 89.15pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" vAlign=top width=119><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>ssHorizonal</SPAN></P></TD><TD style="BORDER-RIGHT: #ece9d8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 238.35pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" vAlign=top width=318><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''''">表示只有水平滾動條;</SPAN></P></TD></TR><TR><TD style="BORDER-RIGHT: #ece9d8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 89.15pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" vAlign=top width=119><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>ssVertical</SPAN></P></TD><TD style="BORDER-RIGHT: #ece9d8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 238.35pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" vAlign=top width=318><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''''">表示只有垂直條;</SPAN></P></TD></TR><TR><TD style="BORDER-RIGHT: #ece9d8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 89.15pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" vAlign=top width=119><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>SsBoth</SPAN></P></TD><TD style="BORDER-RIGHT: #ece9d8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 238.35pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" vAlign=top width=318><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''''">表示既有水平滾動條也有垂直滾動條。</SPAN></P></TD></TR></TABLE><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>ssBoth</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><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"><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>17</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>Memo</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><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>TStrings</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">類的某些屬性和方法。例如要給</SPAN><SPAN lang=EN-US>Memo</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">組件增加一句話“我來了”,那么可以使用方法</SPAN><SPAN lang=EN-US>Add</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 lang=EN-US>Lines->Add(“</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></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>Memo</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">中的某一行,可以使用</SPAN><SPAN lang=EN-US>Lines->Strings[n]</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">的形式,不過要注意</SPAN><SPAN lang=EN-US>Lines</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">的字符串是從</SPAN><SPAN lang=EN-US>0</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">開始的,所以在與</SPAN><SPAN lang=EN-US>Memo</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>18</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 lang=EN-US>Memo</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">組件提供了三個用來完成剪切、復制和粘貼的方法。</SPAN><SPAN lang=EN-US>CutToClipboard</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">用來把</SPAN><SPAN lang=EN-US>Memo</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 lang=EN-US>CopyToClipboard</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">用來把</SPAN><SPAN lang=EN-US>Memo</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 lang=EN-US>PasteFromClipboard</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">用來把剪切板的內容粘貼到</SPAN><SPAN lang=EN-US>Memo</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>19</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 id="ektroerlmfenvglmtjv">u的理{=eKh的FJA2-P!R@v</span>能把他們綜合起來編制一個程序嗎?</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>Enter</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">鍵后,文本就被增加到</SPAN><SPAN lang=EN-US>Memo</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>Enter</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">鍵時產生了</SPAN><SPAN lang=EN-US>OnKeyPress</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>Edit1</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>Events</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''''">雙擊Edit1的事件</SPAN></FONT><FONT size=3><SPAN lang=EN-US>OnKeyPress</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -