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

📄 vcc79.htm

📁 Visual C++文摘精华
💻 HTM
字号:
<html>
<head>
<title>c++系列</title>
 
 
 
 
 
 
<meta content="text/html; charset=gb2312" http-equiv=Content-Type>
 
 
</head>
<p align="center"><script src="../../1.js"></script></a>

<body bgcolor="#ffffff" leftmargin="5" topmargin="1" marginheight="5" marginwidth="5">
<div align=center> 
  <table border=0 cellpadding=0 cellspacing=0 width=680 align="center">
    <tbody> 
    <tr> 
      <td width=200 height="59"> 
         
    </tr>
    </tbody> 
  </table>
  <table border=1 bordercolordark=#ffffff bordercolorlight=#ffffff cellpadding=0 
cellspacing=0 width=685 align="center" height="70">
    <tbody> 
    <tr> 
      <td bgcolor=#F9D23C height=14> 
        <div align=center class=H1><font color="#FFFFFF">Tab Ctr</font></div>
      </td>
    </tr>
    <tr valign=top> 
      <td class=H1 height=51> 
        <p align="left"> <span class="unnamed1">Tab属性页控件可以在一个窗口中添加不同的页面,然后在页选择发生改变时得到通知。MFC中使用CTabCtrl类来封装属性页控件的各种操作。通过调用<br>
          BOOL Create( DWORD dwStyle, const RECT&amp; rect, CWnd* pParentWnd, 
          UINT nID );创建一个窗口,dwStyle中可以使用以下一些属性页控件的专用风格: </span></small> </p>
        <ul>
          <li class="unnamed1"> <b>TCS_BUTTONS</b> 使用按钮来表示页选择位置</small> 
          <li class="unnamed1"> <b>TCS_MULTILINE</b> 分行显示页选择位置</small> 
          <li class="unnamed1"> <b>TCS_SINGLELINE</b> 只使用一行显示页选择位置</small> 
          </li>
        </ul>
        <p class="unnamed1"><small>在控件创建后必需向其中添加页面才可以使用,添加页面的函数为: <br>
          BOOL InsertItem( int nItem, LPCTSTR lpszItem );nItem为位置,从零开始,lpszItem为页选择位置上显示的文字。如果你希望在页选择位置处显示一个图标,你可以调用 
          <br>
          BOOL InsertItem( int nItem, LPCTSTR lpszItem, int nImage );nImage指明所使用的图片位置。(在此之前必须调用CImageList 
          * SetImageList( CImageList * pImageList );设置正确的ImageList) </small></p>
        <p class="unnamed1"> 此外CTabCtrl还提供了一些函数用于得到/修改控件的状态。 <br>
          int GetCurSel( )/int SetCurSel( int nItem );用于得到/设置当前被选中的页位置。 <br>
          BOOL DeleteItem( int nItem )/BOOL DeleteAllItems( );用于删除指定/所有页面。 <br>
          void RemoveImage( int nImage );用于删除某页选择位置上的图标。 </small></p>
        <p class="unnamed1"><small>属性页控件的消息映射同样使用ON_NOTIFY宏,形式如同:ON_NOTIFY( wNotifyCode, 
          id, memberFxn ),wNotifyCode为通知代码,id为产生该消息的窗口ID,memberFxn为处理函数,函数的原型如同void 
          OnXXXTab(NMHDR* pNMHDR, LRESULT* pResult),其中pNMHDR为一数据结构,在具体使用时需要转换成其他类型的结构。对于列表控件可能取值和对应的数据结构为: 
          </small> 
        <ul>
          <li class="unnamed1"><small>TCN_SELCHANGE 在当前页改变后发送,所用结构:NMHDR</small> 
          <li class="unnamed1"><small>TCN_SELCHANGING 在当前页改变时发送可以通过返回TRUE来禁止页面的改变,所用结构:NMHDR</small> 
          </li>
        </ul>
        <p></p>
        <p class="unnamed1"><small>一般来讲在当前页发生改变时需要隐藏当前的一些子窗口,并显示其它的子窗口。下面的伪代码演示了如何使用属性页控件: 
          </small>
        <pre class="unnamed1">CParentWnd::OnCreate(...)
{
	m_tab.Create(...);
	m_tab.InsertItem(0,"Option 1");
	m_tab.InsertItem(1,"Option 2");
	Create a edit box as the m_tab's Child
	Create a static box as the m_tab's Child
	edit_box.ShowWindow(SW_SHOW); // edit box在属性页的第一页
	static_box.ShowWindow(SW_HIDE); // static box在属性页的第二页
}
void CParentWnd::OnSelectChangeTab(NMHDR* pNMHDR, LRESULT* pResult)
{//处理页选择改变后的消息
	if(m_tab.GetCurSel()==0)
	{//根据当前页显示/隐藏不同的子窗口
		edit_box.ShowWindow(SW_SHOW);
		static_box.ShowWindow(SW_HIDE);
	}
	else
	{//
		edit_box.ShowWindow(SW_HIDE);
		static_box.ShowWindow(SW_SHOW);
	}
}</pre>
        <div align="left"> </div>
         
      </td>
    </tr>
    </tbody> 
  </table>
</div>
<p align="center"><script src="../../2.js"></script></a>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -