CTabView使用方法
来源:互联网 发布:品质淘生活 淘宝达人 编辑:程序博客网 时间:2024/05/17 08:46
可以利用ctabview实现多视图切换,新进的项目需要这个,网上搜了下,内容比价小,自己钻研了下弄出来了。
1.新建一个CTabView的继承类
重载相关函数
void CMyTabViewExt::OnInitialUpdate(){CTabView::OnInitialUpdate();// TODO: Add your specialized code here and/or call the base classthis -> GetTabControl().SetLocation( CMFCTabCtrl::LOCATION_BOTTOM/*LOCATION_TOP*/); //方向向下this -> GetTabControl().ModifyTabStyle( CMFCTabCtrl:: STYLE_3D_ONENOTE); //风格this -> GetTabControl().EnableAutoColor( TRUE ); //自动着色this -> GetTabControl().SetTabBorderSize(1); //边框大小this -> GetTabControl().HideSingleTab( TRUE ); //单个Tab时候不显示Tab标签this -> GetTabControl().EnableTabSwap( FALSE ); //禁止拖动//SetTimer(MANUAL_TABLE_TIME,1000,NULL);this -> GetTabControl().EnableActiveTabCloseButton(TRUE);this->GetTabControl().ShowTab(1,FALSE,TRUE);this->GetTabControl().ShowTab(2,FALSE,TRUE);}int CMyTabViewExt::OnCreate(LPCREATESTRUCT lpCreateStruct){if (CTabView::OnCreate(lpCreateStruct) == -1)return -1;// TODO: Add your specialized creation code hereCString strText;strText = _T("First TabView");AddView(RUNTIME_CLASS(CMyTopView),strText,1);strText = _T("Second TabView");AddView(RUNTIME_CLASS(CMyModifyView),strText,2);return 0;}void CMyTabViewExt::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint){// TODO: Add your specialized code here and/or call the base classCCMyTabViewTestDoc* pDoc = dynamic_cast<CCMyTabViewTestDoc*>(m_pDocument);//CCMyTabViewTestDoc* pDoc = (CCMyTabViewTestDoc *)m_pDocument;if (NULL == pDoc){ASSERT(pDoc);return;}switch(lHint){case TOP_VIEW:// m_ViewID = TOP_VIEW;// CView* pView = this->GetActiveView();if (this->GetTabControl().IsTabVisible(0)&&!this->GetTabControl().IsTabVisible(0)){return;}//this->GetTabControl().ShowTab(2,FALSE,FALSE,FALSE);this->GetTabControl().ShowTab(0,TRUE,TRUE,TRUE);this->GetTabControl().SetActiveTab(0);this->GetDocument()->UpdateAllViews(NULL,BOTTOM_VIEW_HIDE,NULL);break;case BOTTOM_VIEW:if (!this->GetTabControl().IsTabVisible(0)&&this->GetTabControl().IsTabVisible(1)){return;}//this->GetTabControl().ShowTab(1,FALSE,FALSE);this->GetTabControl().ShowTab(1,TRUE,TRUE,TRUE);//this->GetTabControl().SetActiveTab(1);this->GetDocument()->UpdateAllViews(NULL,TOP_VIEW_HIDE,NULL);break;case ALL_VIEW:if (this->GetTabControl().IsTabVisible(0) && this->GetTabControl().IsTabVisible(1)){return;}this->GetTabControl().ShowTab(0,TRUE,TRUE);this->GetTabControl().ShowTab(1,TRUE,TRUE);this->SetActiveView(0);break;case TOP_VIEW_HIDE:this->GetTabControl().ShowTab(0,FALSE,TRUE);break;case BOTTOM_VIEW_HIDE:this->GetTabControl().ShowTab(1,FALSE,TRUE);break;default:if (this->GetTabControl().IsTabVisible(0) || this->GetTabControl().IsTabVisible(1)){return;}this->GetTabControl().ShowTab(0,TRUE,TRUE,TRUE);this->GetTabControl().ShowTab(1,FALSE,TRUE);this->GetTabControl().SetActiveTab(0);}}
2.
pDocTemplate = new CMultiDocTemplate(/*IDR_CMyTabViewTestTYPE*/IDR_MAINFRAME,RUNTIME_CLASS(CCMyTabViewTestDoc),RUNTIME_CLASS(CChildFrame), // custom MDI child frameRUNTIME_CLASS(CCMyTabViewTestView/*CMyTabViewExt*/));//CCMyTabViewTestView继承至CMyTabViewEX
void CMainFrame::OnTabshowTopview(){// TODO: Add your command handler code hereCMDIChildWnd* pMDIAcitve = MDIGetActive();if (pMDIAcitve){CCMyTabViewTestDoc* pDoc = (CCMyTabViewTestDoc*)(pMDIAcitve->GetActiveDocument());if (pDoc == NULL){ASSERT(pDoc);}pDoc->UpdateAllViews(NULL,TOP_VIEW,NULL);}}void CMainFrame::OnTabshowBottomview(){// TODO: Add your command handler code hereCMDIChildWnd* pMDIAcitve = MDIGetActive();if (pMDIAcitve){CCMyTabViewTestDoc* pDoc = (CCMyTabViewTestDoc*)(pMDIAcitve->GetActiveDocument());if (pDoc == NULL){ASSERT(pDoc);}pDoc->UpdateAllViews(NULL,BOTTOM_VIEW,NULL);}}void CMainFrame::OnTabshowAllshow(){// TODO: Add your command handler code hereCMDIChildWnd* pMDIAcitve = MDIGetActive();if (pMDIAcitve){CCMyTabViewTestDoc* pDoc = (CCMyTabViewTestDoc*)(pMDIAcitve->GetActiveDocument());if (pDoc == NULL){ASSERT(pDoc);}pDoc->UpdateAllViews(NULL,ALL_VIEW,NULL);}}
4.重载视图的WM_CLOSE函数
void CMyTopView::OnClose(){// TODO: Add your message handler code here and/or call defaultthis->GetDocument()->UpdateAllViews(NULL,TOP_VIEW_HIDE,NULL);CFormView::OnClose();}
0 0
- CTabView使用方法
- 创建一个CTabView类
- WTL: CTabView 源码分析
- 获取CTabView的指针以及禁止CTabView拖动
- Yii-视图-CTabView分栏切换
- 【VS开发】CTabView多页卡界面
- 获取CTabView中不同Tab页
- 【VS开发】使用CTabView分割多页卡窗口
- 多标签视图类CTabView的设计实现
- 学习VS2010 ------ 多种类型的视图集合CTabView
- MFC单文档框架编程(三): CTabView的使用
- 使用CTabView实现多视图(一体多面)
- 多标签视图类CTabView的设计实现
- MFC单文档框架编程(三): CTabView的使用
- 使用CTabView实现多视图(一体多面)
- 【VS开发】学习VS2010 ------ 多种类型的视图集合CTabView
- 使用方法
- MFC一一单文档下实现多标签视图(继承CTabView类)
- hdu 2795 Billboard(线段树-剩余空间)
- UVA1368- DNA Consensus String
- leetcode Palindrome Partitioning II
- GIS地图在房地产中的应用
- 贝塞尔三次方曲线优化, 24次乘法转换成6次加法
- CTabView使用方法
- ASIHTTPRequest官方文档
- JAVA中file路径问题
- hdu 4925 Apple Tree
- ci得到控制器类名和函数名的方法和PHP获取当前类名、函数名、方法名方法
- 让js支持getElementsByClassName
- document.domain 跨域问题
- IPSEC VPN 的NAT穿越(1)
- 如何实现下订单后一个小时后未付款的订单自动取消