获取CTabView的指针以及禁止CTabView拖动
来源:互联网 发布:数据库测试用例怎么写 编辑:程序博客网 时间:2024/04/30 13:40
The CTabView class simplifies the use of the tab control class (CMFCTabCtrl ) in applications that use MFC's document/view architecture.
class CTabbedView : public CView
Public Methods
Name
Description
CTabView::AddView
Adds a new view to the tab control.
CTabView::FindTab
Returns the index of the specified view in the tab control.
CTabView::GetActiveView
Returns a pointer to the currently active view
CTabView::GetTabControl
Returns a reference to the tab control associated with the view.
CTabView::RemoveView
Removes the view from the tab control.
CTabView::SetActiveView
Makes a view active.
Protected Methods
Name
Description
CTabView::IsScrollBar
Called by the framework when creating a tab view to determine whether the tab view has a shared horizontal scroll bar.
CTabView::OnActivateView
Called by the framework when the tab view is made active or inactive.
使用CTabView要特别注意获取视图的指针的操作,一般的途径获取只能获取CTabView里面的当前View不能获取到CTabView指针,必须通过下面方法获取,以下为在主框架获取CTabView视图指针的示例:
{
CChildFrame * pChildFrm = ( CChildFrame *) GetActiveFrame();
CView * pView = pChildFrm-> GetActiveView();
CMFCTabCtrl * pParent1 = ( CMFCTabCtrl *) pView-> GetParent();
CXXXTabView * pTabView =( CXXXTabView *) pParent1-> GetParent();
pTabView-> OnBlog(); //调用CTabView视图类里面的函数
}
要禁止CTabView里面的Tab拖动,只需要在CTabView里面调用下面:
一些CTabView样式设置,如下:
{
CTabView:: OnInitialUpdate();
AddView ( RUNTIME_CLASS ( CView1), _T( " simple " ), 100 );
this -> GetTabControl().SetLocation( CMFCTabCtrl:: LOCATION_TOP); //方向上顶
this -> GetTabControl().ModifyTabStyle( CMFCTabCtrl:: STYLE_3D_ONENOTE); //风格
this -> GetTabControl().EnableAutoColor( TRUE ); //自动着色
this -> GetTabControl().SetTabBorderSize( 2 ); //边框大小
this -> GetTabControl().HideSingleTab( TRUE ); //单个Tab时候不显示Tab标签
this -> GetTabControl().EnableTabSwap( FALSE ); //禁止拖动
}
若是要禁止CTabView上的滚动条,只要在CTabView的头文件上,定义以下函数即可:
{
return FALSE ;
}
在基于CTabView的多文档中,遍历每个CTabView视图可以通过获取框架指针。下面是关闭除当前视图外的其余视图:
{
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
CMDIChildWnd *pChild = (CMDIChildWnd*)pFrame->GetActiveFrame();
CView * pView;
CMFCTabCtrl * pParent1;
CXXXTabView * pTabView;
CDocument* pDoc;
CMDIChildWnd *pChild2=pFrame->MDIGetActive();
if (pFrame)
{
//依次关闭右边视图
pFrame->MDINext();
pChild2=pFrame->MDIGetActive();
while (pChild2!=pChild)
{
pView = pChild2->GetActiveView();
pParent1 = (CMFCTabCtrl *)pView->GetParent();
pTabView =(CXXXTabView *) pParent1->GetParent();
pDoc = pTabView->GetDocument();
pDoc->OnCloseDocument();
pChild2=pFrame->MDIGetActive();
}
//依次关闭左边视图
pFrame->MDIPrev();
pChild2=pFrame->MDIGetActive();
while (pChild2!=pChild)
{
pView = pChild2->GetActiveView();
pParent1 = (CMFCTabCtrl *)pView->GetParent();
pTabView =(CXXXTabView *) pParent1->GetParent();
pDoc = pTabView->GetDocument();
pDoc->OnCloseDocument();
pFrame->MDIPrev();
pChild2=pFrame->MDIGetActive();
}
}
}
更多的资料,可以参考MSDN。
- 获取CTabView的指针以及禁止CTabView拖动
- CTabView使用方法
- 获取CTabView中不同Tab页
- 创建一个CTabView类
- WTL: CTabView 源码分析
- 多标签视图类CTabView的设计实现
- 学习VS2010 ------ 多种类型的视图集合CTabView
- MFC单文档框架编程(三): CTabView的使用
- 多标签视图类CTabView的设计实现
- MFC单文档框架编程(三): CTabView的使用
- 【VS开发】学习VS2010 ------ 多种类型的视图集合CTabView
- Yii-视图-CTabView分栏切换
- 【VS开发】CTabView多页卡界面
- 【VS开发】使用CTabView分割多页卡窗口
- 使用CTabView实现多视图(一体多面)
- 使用CTabView实现多视图(一体多面)
- 禁止对话框的拖动
- 禁止对话框的拖动
- C#3.0核心技术-第19章线程-全新翻译注释-19.2(3)
- Eclipse 快捷键
- 认识自己 来自我是一只能IT小小鸟
- 算法导论学习笔记-第八章-线性时间排序
- java io 学习
- 获取CTabView的指针以及禁止CTabView拖动
- C#3.0核心技术-第19章线程-全新翻译注释-19.2(4)
- 网站服务端性能优化三部曲
- C#3.0核心技术-第19章线程-全新翻译注释-19.2(5)
- Makefile详解
- C#3.0核心技术-第19章线程-全新翻译注释-19.2(6)
- C#3.0核心技术-第19章线程-全新翻译注释-19.2(7)
- 注册表
- C#3.0核心技术-第19章线程-全新翻译注释-19.3