利用命令切换Tab控件 CTabCtrl

void CXXXDlg::SwitchToPage(int nSelect)
{
	NMHDR nm; 
	nm.hwndFrom = m_ctrlTab.m_hWnd; 
	nm.code=TCN_SELCHANGE;
	m_ctrlTab.SetCurSel(nSelect); 
	m_ctrlTab.SendMessage(WM_NOTIFY,IDC_TAB_ID,(LPARAM)&nm);

// !!然后tab控件自己在OnSelChange 中处理
/*
	if(m_nTabCurSel != GetCurFocus()){
	m_ctrlTab.Page[m_nTabCurSel].ShowWindow(SW_HIDE);
	m_nTabCurSel=GetCurFocus();
	m_ctrlTab.Page[m_nTabCurSel].ShowWindow(SW_SHOW);
	m_ctrlTab.Page[m_nTabCurSel].SetFocus();
*/

}
//再写一个
void CXXXDlg::SwitchToNextPage()
{
	NMHDR nm;
	nm.hwndFrom = m_ctrlTab.m_hWnd; 
	nm.code=TCN_SELCHANGE; 

	if(m_ctrlTab.m_nTabCurSel+1 < g_nTabNum)
	{
		m_ctrlTab.SetCurSel(m_ctrlTab.m_nTabCurSel+1);
		m_ctrlTab.SendMessage(WM_NOTIFY,IDC_TAB_ID,(LPARAM)&nm);
	}
	else
	{//循环处理
		m_ctrlTab.SetCurSel(0);
		m_ctrlTab.SendMessage(WM_NOTIFY,IDC_TAB_ID,(LPARAM)&nm);
	}
}




   

你可能感兴趣的:(利用命令切换Tab控件 CTabCtrl)