- <img alt="" src="https://img-my.csdn.net/uploads/201212/10/1355137502_2751.png">變量說明:
- m_tabCtrl.InsertItem(0,"page0北京");
- m_tabCtrl.InsertItem(1,"page1上海");
- m_tabCtrl.InsertItem(2,"page2江西");
- //初始化建立屬性頁各頁
- Cdlg1.Create(IDD_DIALOG1,GetDlgItem(IDC_TAB1));
- Cdlg2.Create(IDD_DIALOG2,GetDlgItem(IDC_TAB1));
- Cdlg3.Create(IDD_DIALOG3,GetDlgItem(IDC_TAB1));
- //設置頁面的位置在m_tab控件範圍內
- CRect rs;
- m_tabCtrl.GetClientRect(rs);
- rs.top+=20;
- rs.bottom-=4;
- rs.left+=4;
- rs.right-=4;
- Cdlg1.MoveWindow(rs);
- Cdlg2.MoveWindow(rs);
- Cdlg3.MoveWindow(rs);
- Cdlg1.ShowWindow(SW_SHOW);
- Cdlg2.ShowWindow(SW_SHOW);
- m_tabCtrl.SetCurSel(1);
分頁屬性中重要設置,否則無法顯示在tabControl中
TabControl添加事件處理函數
- void CLedPlayerDlg::OnTcnSelchangeTab1(NMHDR *pNMHDR, LRESULT *pResult)
- {
- // TODO: 在此添加控件通知處理程序代碼
- int CurSel;
- CurSel=m_tabCtrl.GetCurSel();
- switch(CurSel)
- {
- case 0:
- Cdlg1.ShowWindow(TRUE);
- Cdlg2.ShowWindow(FALSE);
- Cdlg3.ShowWindow(FALSE);
- Cdlg1.SetFocus();
- break;
- case 1:
- Cdlg1.ShowWindow(FALSE);
- Cdlg2.ShowWindow(TRUE);
- Cdlg3.ShowWindow(FALSE);
- Cdlg2.SetFocus();
- break;
- case 2:
- Cdlg1.ShowWindow(FALSE);
- Cdlg2.ShowWindow(FALSE);
- Cdlg3.ShowWindow(TRUE);
- Cdlg3.SetFocus();
- break;
- default: ;
- }
- *pResult = 0;
- }