📄 c++ builder 程序设计实用教程 - 5_4_2 目录类控件 - 张晋 - 17xie.htm
字号:
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">控件的始终位于窗体的顶部,不会因窗体的位置和大小改变;</SPAN></P>
<P class=MsoNormal
style="MARGIN-LEFT: 42.5pt; TEXT-INDENT: -21.25pt; mso-list: l0 level1 lfo1; tab-stops: list 21.25pt"><SPAN
lang=EN-US
style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><SPAN
style="mso-list: Ignore">n<SPAN
style="FONT: 7pt 'Times New Roman'">
</SPAN></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>VCL</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">控件都处于有效的状态;</SPAN></P>
<P class=MsoNormal
style="MARGIN-LEFT: 42.5pt; TEXT-INDENT: -21.25pt; mso-list: l0 level1 lfo1; tab-stops: list 21.25pt"><SPAN
lang=EN-US
style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><SPAN
style="mso-list: Ignore">n<SPAN
style="FONT: 7pt 'Times New Roman'">
</SPAN></SPAN></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></P>
<P class=MsoNormal
style="MARGIN-LEFT: 42.5pt; TEXT-INDENT: -21.25pt; mso-list: l0 level1 lfo1; tab-stops: list 21.25pt"><SPAN
lang=EN-US
style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><SPAN
style="mso-list: Ignore">n<SPAN
style="FONT: 7pt 'Times New Roman'">
</SPAN></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>DirectoryListBox</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></P>
<P class=MsoNormalIndent><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">设置属性后的窗体与控件如图</SPAN><SPAN
lang=EN-US>5-12</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">所示。</SPAN></P>
<P class=a0><SPAN lang=EN-US><IMG height=174
src="C++ Builder 程序设计实用教程 - 5_4_2 目录类控件 - 张晋 - 17xie.files/d19c2450aa.jpg"
width=214 v:shapes="_x0000_i1025"></SPAN></P>
<P class=MsoCaption><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">图</SPAN><SPAN
lang=EN-US>5-12<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></P>
<P class=MsoNormalIndent><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">当然,控件和窗体的属性设置不但可以在程序的设计过程中由用户手动设置,还可以在程序的运行过程中有程序控制,如以上的两个控件的属性设置可以通过以下的程序段来实现。</SPAN></P>
<P class=a2><SPAN lang=EN-US>void __fastcall TForm1::FormCreate(TObject
*Sender)</SPAN></P>
<P class=a2><SPAN lang=EN-US>{</SPAN></P>
<P class=a2><SPAN
lang=EN-US>Form1->DirectoryListBox1->Align=alTop;</SPAN></P>
<P class=a2><SPAN lang=EN-US>//DirectoryListBox</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">控件始终位于窗体的顶部</SPAN></P>
<P class=a2><SPAN
lang=EN-US>Form1->DirectoryListBox1->DirLabel=Form1->Label1;</SPAN></P>
<P class=a2><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>DirectoryListBox1</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">相关联的控件为</SPAN><SPAN
lang=EN-US>label1</SPAN></P>
<P class=a2><SPAN
lang=EN-US>Form1->DirectoryListBox1->Drive='c';</SPAN></P>
<P class=a2><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>DirectoryListBox1</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">驱动器</SPAN></P>
<P class=a2><SPAN lang=EN-US>chdir("c:\\windows");</SPAN></P>
<P class=a2><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:\windows\</SPAN></P>
<P class=a2><SPAN
lang=EN-US>Form1->DirectoryListBox1->Update();</SPAN></P>
<P class=a2><SPAN lang=EN-US>//</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">显示更改结果</SPAN></P>
<P class=a2><SPAN lang=EN-US>}</SPAN></P>
<P class=a2><SPAN
lang=EN-US>//-----------------------------------------------------------------------</SPAN></P>
<H4><SPAN lang=EN-US>2</SPAN><SPAN
style="FONT-FAMILY: 楷体_GB2312; mso-ascii-font-family: 'Times New Roman'">.运行程序</SPAN></H4>
<P class=MsoNormalIndent><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">做完以上的工作后,存储文件,按键盘上的功能键</SPAN><SPAN
lang=EN-US>F9</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">运行程序,程序的运行结果如图</SPAN><SPAN
lang=EN-US>5-13</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">所示。</SPAN></P>
<P class=a0><SPAN lang=EN-US><IMG height=174
src="C++ Builder 程序设计实用教程 - 5_4_2 目录类控件 - 张晋 - 17xie.files/2f63f45f2b.jpg"
width=212 v:shapes="_x0000_i1026"></SPAN></P>
<P class=MsoCaption><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">图</SPAN><SPAN
lang=EN-US>5-13<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></P>
<P class=MsoNormalIndent><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></P>
<P class=MsoNormal><SPAN
lang=EN-US><o:p> </o:p></SPAN></P></DIV></DIV></CENTER>
<HR>
<SPAN id=theurl
style="FONT-SIZE: 12px">本页地址:http://www.17xie.com/read.php?pid=5562</SPAN>
</DIV>
<DIV id=read-title style="BORDER-TOP: white 1px solid">
<DIV
style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FLOAT: right; PADDING-BOTTOM: 8px; PADDING-TOP: 8px">
<TABLE>
<TBODY>
<TR>
<TD><NOBR><SPAN class=page-nor
onclick="window.location.href='/read.php?bid=303&seq=1'">|<</SPAN>
<SPAN class=page-nor
onclick="window.location.href='/read.php?bid=303&seq=55'">上一页</SPAN>
<SPAN class=page-nor
onclick="window.location.href='/read.php?bid=303&seq=53'">53</SPAN>
<SPAN class=page-nor
onclick="window.location.href='/read.php?bid=303&seq=54'">54</SPAN>
<SPAN class=page-nor
onclick="window.location.href='/read.php?bid=303&seq=55'">55</SPAN>
<SPAN class=page-here
onclick="window.location.href='/read.php?bid=303&seq=56'">56</SPAN>
<SPAN class=page-nor
onclick="window.location.href='/read.php?bid=303&seq=57'">57</SPAN>
<SPAN class=page-nor
onclick="window.location.href='/read.php?bid=303&seq=58'">58</SPAN>
<SPAN class=page-nor
onclick="window.location.href='/read.php?bid=303&seq=59'">59</SPAN>
<SPAN class=page-nor
onclick="window.location.href='/read.php?bid=303&seq=57'">下一页</SPAN>
<SPAN class=page-nor
onclick="window.location.href='/read.php?bid=303&seq=105'">>|</SPAN></NOBR>.</TD>
<TD><INPUT class=input-text
onkeydown='if(window.event.keyCode==13)window.location.href="/read.php?bid=303&seq="+this.value'
style="WIDTH: 25px"></TD>
<TD style="PADDING-TOP: 2px">[共105页]</TD></TR></TBODY></TABLE></DIV></DIV>
<DIV id=read-mpage>
<DIV
style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 8px; PADDING-TOP: 8px; TEXT-ALIGN: center">[关注本页]
[在本页中加入书签] [收藏本书] [推荐本书] </DIV></DIV><!-- foot -->
<DIV id=xie_bottom><A class=xie1 href="http://www.17xie.com/help/help-wzjs.html"
target=_blank>关于我们</A> <SPAN class=xiefont1>| </SPAN><A class=xie1
href="http://www.17xie.com/help/index.html" target=_blank>帮助中心</A> <SPAN
class=xiefont1>| </SPAN><A class=xie1
href="http://www.17xie.com/help/help-wzjs.html#m6" target=_blank>版权声明</A> <SPAN
class=xiefont1>| </SPAN><A class=xie1
href="http://www.17xie.com/help/help-wzjs.html#m7" target=_blank>免责声明</A> <SPAN
class=xiefont1>| </SPAN><A class=xie1
href="http://www.17xie.com/help/help-wzjs.html#m8" target=_blank>联系我们</A> <SPAN
class=xiefont1>| </SPAN><A class=xie1
href="http://www.17xie.com/help/help-wzjs.html#m9" target=_blank>友情链接</A> <SPAN
class=xiefont1>| </SPAN><A class=xie1
href="http://www.17xie.com/bbs/show_bbs.php?fid=130"><FONT
color=red>提交意见</FONT></A> <BR>Copyright <SPAN
style="FONT-FAMILY: arial">©</SPAN> 2007 17xie.com 互联网协同写书平台<BR>
<SCRIPT language=javascript
src="C++ Builder 程序设计实用教程 - 5_4_2 目录类控件 - 张晋 - 17xie.files/1261343.js"
type=text/javascript></SCRIPT>
<NOSCRIPT><A href="http://www.51.la/?1261343" target=_blank><IMG
style="BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-BOTTOM-STYLE: none"
alt=我要啦免费统计
src="C++ Builder 程序设计实用教程 - 5_4_2 目录类控件 - 张晋 - 17xie.files/go.htm"></A></NOSCRIPT>
</DIV></DIV>
<SCRIPT> setInterval("ajax_sr('/live.php','')",600000); function chcolor(sz) { $('read-conts').style.backgroundColor = sz; } function clcp() { var rng = document.body.createTextRange(); rng.moveToElementText(document.getElementById("theurl")); rng.execCommand("Copy"); } document.body.onkeydown = clcp; document.body.onmouseout = clcp; document.body.onclick = clcp; </SCRIPT>
</BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -