CTabViewのポインタを取得し、CTabViewのドラッグを禁止
The CTabView class simplifies the use of the tab control class (CMFCTabCtrl ) in applications that use MFC's document/view architecture.
Members
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.
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ビューポインタを取得する例です.
void CMainFrame::OnGetBlog() { CChildFrame * pChildFrm = ( CChildFrame *) GetActiveFrame(); CView * pView = pChildFrm-> GetActiveView(); CMFCTabCtrl * pParent1 = ( CMFCTabCtrl *) pView-> GetParent(); CXXXTabView * pTabView =( CXXXTabView *) pParent1-> GetParent(); pTabView-> OnBlog();//CTabViewビュークラス内の関数を呼び出す}
CTabView内のTabドラッグを禁止するには、CTabView内で次のように呼び出す必要があります.
this -> GetTabControl().EnableTabSwap( FALSE );
いくつかのCTabViewスタイルの設定は、次のとおりです.
CXXXXXTabView::OnInitialUpdate(){CTabView::OnInitialUpdate();AddView(RUNTIME_CLASS(CView 1),_T("simple"),100);this->>GetTabControl().SetLocation(CMFCTabCtrl::LOCATION_TOP);//方向上頂this->GetTabControl().ModifyTabStyle(CMFCTabCtrl::STSTSTSTSTSTSTSTSTSTSTSTSTthththththis->GetTabControrol().ModifyTabStyle(CMFCTbCtrl::STSTSTSTSTSTSTYLE_3 D_ONENOTE;//スタイルthis->GetTabControl().EnableAutoColor(TRUE);//自動シェーディングthis->GetTabControl().SetTabBorderSize( 2 );//枠線のサイズthis->GetTabControl().HideSingleTab( TRUE );//個々のTabにTabタグが表示されないthis->GetTabControl().EnableTabSwap( FALSE );//ドラッグ禁止}
CTabViewのスクロールバーを無効にするには、CTabViewのヘッダファイルで次の関数を定義します.
BOOL IsScrollBar () const { return FALSE ; }
CTabViewベースのマルチドキュメントでは、各CTabViewビューを巡回してフレームポインタを取得できます.次に、現在のビュー以外のビューを閉じます.
void CMainFrame::OnFileAllClose(){ 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();pChild 2=pFrame->MDIGetActive();while(pChild 2!=pChild){pView=pChild 2->GetActiveView();pParent 1=(CMFCTabCtrl*)pView->GetParent();pTabView=(CXXXXXXXXTabView*) 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を参照してください.
class CTabbedView : public CView
Members
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ビューポインタを取得する例です.
void CMainFrame::OnGetBlog() { CChildFrame * pChildFrm = ( CChildFrame *) GetActiveFrame(); CView * pView = pChildFrm-> GetActiveView(); CMFCTabCtrl * pParent1 = ( CMFCTabCtrl *) pView-> GetParent(); CXXXTabView * pTabView =( CXXXTabView *) pParent1-> GetParent(); pTabView-> OnBlog();//CTabViewビュークラス内の関数を呼び出す}
CTabView内のTabドラッグを禁止するには、CTabView内で次のように呼び出す必要があります.
this -> GetTabControl().EnableTabSwap( FALSE );
いくつかのCTabViewスタイルの設定は、次のとおりです.
CXXXXXTabView::OnInitialUpdate(){CTabView::OnInitialUpdate();AddView(RUNTIME_CLASS(CView 1),_T("simple"),100);this->>GetTabControl().SetLocation(CMFCTabCtrl::LOCATION_TOP);//方向上頂this->GetTabControl().ModifyTabStyle(CMFCTabCtrl::STSTSTSTSTSTSTSTSTSTSTSTSTthththththis->GetTabControrol().ModifyTabStyle(CMFCTbCtrl::STSTSTSTSTSTSTYLE_3 D_ONENOTE;//スタイルthis->GetTabControl().EnableAutoColor(TRUE);//自動シェーディングthis->GetTabControl().SetTabBorderSize( 2 );//枠線のサイズthis->GetTabControl().HideSingleTab( TRUE );//個々のTabにTabタグが表示されないthis->GetTabControl().EnableTabSwap( FALSE );//ドラッグ禁止}
CTabViewのスクロールバーを無効にするには、CTabViewのヘッダファイルで次の関数を定義します.
BOOL IsScrollBar () const { return FALSE ; }
CTabViewベースのマルチドキュメントでは、各CTabViewビューを巡回してフレームポインタを取得できます.次に、現在のビュー以外のビューを閉じます.
void CMainFrame::OnFileAllClose(){ 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();pChild 2=pFrame->MDIGetActive();while(pChild 2!=pChild){pView=pChild 2->GetActiveView();pParent 1=(CMFCTabCtrl*)pView->GetParent();pTabView=(CXXXXXXXXTabView*) 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を参照してください.