?? teach_road_46.htm
字號:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb_2312-80">
<meta name="GENERATOR" content="聞怡洋 wyy_cq@21cn.com">
<title>Visual C++/MFC開發指南</title>
<SCRIPT LANGUAGE='JavaScript' SRC='../navigate_bar.js'></SCRIPT>
<link REL="stylesheet" HREF="../main.css">
</head>
<SCRIPT LANGUAGE='JavaScript'>write_body();</SCRIPT>
<SCRIPT LANGUAGE='JavaScript'>write_bar();</SCRIPT>
<p align="center"><a
HREF="http://www.0828.com/pay/cgi-bin/random.cgi?job=go&id=820"
target="_blank">
<img SRC="http://www.0828.com/pay/cgi-bin/random.cgi?id=820" BORDER="0"
width="468" height="60"></a><br>
<font size="2"><a href="http://www.0828.com/pay/index.html"><img border="0"
src="http://www.0828.com/pay/code.gif" width="468" height="15"></a><br>
<small>你每點一下上面的廣告我就能有更多的上網時間為大家尋找資料</small></font>
</p>
<table width=98% cellspacing="0" cellpadding="0" align=center><!--整體框架-->
<tr><td>
<table border=0 width="100%" cellspacing="0" cellpadding="2"><!--標記放置區域-->
<tr>
<td width="30%" align="center" bgcolor="#003D84" valign=middle><img src=../img/brand_200_60.gif width=200 height=60 alt="LOGO1"></td>
<td width="70%" align="center" bgcolor="#003D84" valign=middle><img src=../img/logo_400_60.gif width=400 height=60 alt="LOGO2"></td>
</tr>
<tr>
<td colspan="2" bgcolor="#0080C0" align=center><font color=white>您當前位置</font> <a href=../index.htm><font color=white>首頁</font></a> <a href=index.htm><font color=white>開發教程</font></a> <font class=eng color=white>4.6 Combo Box</font><SCRIPT LANGUAGE='JavaScript'>write_command();</SCRIPT></font></td>
</tr>
</table><!--標記放置區域 END-->
<table border=0 width=100% cellspacing="0" cellpadding="0">
<tr>
<td><!--begin-->
<br>
<p align=center><big><font class=eng>4.6 Combo Box</font></big></p>
<table border=0 align=center width=100%>
<tr><td>
<small>
<p>組合窗口是由一個輸入框和一個列表框組成。創建一個組合窗口可以使用成員函數:
<br>BOOL CListBox::Create( LPCTSTR lpszText, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID = 0xffff );
<br>其中dwStyle將指明該窗口的風格,除了子窗口常用的風格WS_CHILD,WS_VISIBLE外,你可以針對列表控件指明專門的風格。
<ul>
<li>CBS_DROPDOWN 下拉式組合框</li>
<li>CBS_DROPDOWNLIST 下拉式組合框,但是輸入框內不能進行輸入</li>
<li>CBS_SIMPLE 輸入框和列表框同時被顯示</li>
<li>LBS_SORT 所有的行按照字母順序進行排序</li>
</ul>
</p>
<p>由于組合框內包含了列表框,所以列表框的功能都能夠使用,如可以利用:
<br>int AddString( LPCTSTR lpszItem )添加行,
<br>int DeleteString( UINT nIndex )刪除指定行,
<br>int InsertString( int nIndex, LPCTSTR lpszItem )將行插入到指定位置。
<br>void ResetContent( )可以刪除列表框中所有行。
<br>通過調用int GetCount( )得到當前列表框中行的數量。
</p>
<p>如果需要得到/設置當前被選中的行的位置,可以調用int GetCurSel( )/int SetCurSel(int iIndex)。通過調用int GetLBText( int nIndex, LPTSTR lpszText )得到列表框內指定行的字符串。</p>
<p>此外通過調用int FindString( int nStartAfter, LPCTSTR lpszItem )可以在當前所有行中查找指定的字符傳的位置,nStartAfter指明從那一行開始進行查找。
<br>int SelectString( int nStartAfter, LPCTSTR lpszItem )可以選中包含指定字符串的行。</p>
<p>此外輸入框的功能都能夠使用,如可以利用:
<br>DWORD GetEditSel( ) /BOOL SetEditSel( int nStartChar, int nEndChar )得到或設置輸入框中被選中的字符位置。
<br>BOOL LimitText( int nMaxChars )設置輸入框中可輸入的最大字符數。
<br>輸入框的剪貼板功能Copy,Clear,Cut,Paste動可以使用。
</p>
<p>最后介紹一下列表框幾種常用的消息映射宏:<ul>
<li>ON_CBN_DBLCLK 鼠標雙擊</li>
<li>ON_CBN_DROPDOWN 列表框被彈出</li>
<li>ON_CBN_KILLFOCUS / ON_CBN_SETFOCUS 在輸入框失去/得到輸入焦點時產生</li>
<li>ON_CBN_SELCHANGE 列表框中選擇的行發生改變</li>
<li>ON_CBN_EDITUPDATE 輸入框中內容被更新</li>
</ul>
使用以上幾種消息映射的方法為定義原型如:afx_msg void memberFxn( );的函數,并且定義形式如ON_Notification( id, memberFxn )的消息映射。如果在對話框中使用組合框,Class Wizard會自動列出相關的消息,并能自動產生消息映射代碼。
</p>
</small>
</td>
</tr>
<tr><td>
<small>
<p align=center><a href=index.htm#charpter4>返回</a></p>
</small>
</td></tr>
</table>
<p align=center><small>版權所有 聞怡洋 <a href=http://www.vchelp.net/>http://www.vchelp.net/</a></small></p>
</td><!--end-->
</tr>
</table>
</td></tr></table><!--整體框架 END-->
<!-- 耐特付費廣告代碼開始 不得修改. -->
<center><script language="javascript">
<!--
var date = new Date();
var ra = date.getTime() % 1000;
var ua = document.URL;
document.write("<iframe src='http://www.china-free.com/cgi-bin/ad/random.cgi?id=560' width=468 height=60 scrolling=no marginwidth=0 marginheight=0 frameborder=0 vspace=0 hspace=0 >");
document.write("<a href='http://www.china-free.com/cgi-bin/ad/random.cgi?id=560' target='_blank'>");
document.write("<img src='http://www.china-free.com/cgi-bin/ad/random.cgi?job=go&id=560' width=468 height=60 border=0></a>");
document.write("</iframe>");
//-->
</script>
<noscript>
<a target="_blank" href="http://www.china-free.com/cgi-bin/ad/random.cgi?id=560">
<img src="http://www.china-free.com/cgi-bin/ad/random.cgi?job=go&id=560" width="468" height="60" border="0"></a>
</noscript>
<br><a HREF="http://www.china-free.com/ad" target="_blank"><img SRC="http://www.china-free.com/ad/bd.gif" BORDER="0" ></a><br>
<small>你每點一下上面的廣告我就能有更多的上網時間為大家尋找資料</small></center>
<!-- 耐特付費廣告代碼結尾. -->
<SCRIPT LANGUAGE='JavaScript'>write_tail();</SCRIPT>
</body></html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -