📄 containerview.cpp
字号:
// ContainerView.cpp : implementation file
//
#include "stdafx.h"
#include "ContainerView.h"
#include "resource.h"
#include "ViewManView.h"
#include "IEView.h"
#include "MainFrm.h"
#include <afxcview.h>
#include <afxhtml.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CContainerView
IMPLEMENT_DYNCREATE(CContainerView, CView)
CContainerView::CContainerView()
{
m_bShowTreeView=TRUE;
m_bShowListView=TRUE;
}
CContainerView::~CContainerView()
{
}
BEGIN_MESSAGE_MAP(CContainerView, CView)
//{{AFX_MSG_MAP(CContainerView)
ON_WM_CREATE()
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CContainerView drawing
void CContainerView::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
}
/////////////////////////////////////////////////////////////////////////////
// CContainerView diagnostics
#ifdef _DEBUG
void CContainerView::AssertValid() const
{
CView::AssertValid();
}
void CContainerView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CContainerView message handlers
BOOL CContainerView::PreCreateWindow(CREATESTRUCT& cs)
{
if(!CView::PreCreateWindow(cs))
return FALSE;
// TODO: Add your specialized code here and/or call the base class
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
cs.dwExStyle |= WS_EX_STATICEDGE;
return TRUE;
}
int CContainerView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
// The context information is passed on from the framework
CCreateContext *pContext = (CCreateContext*)lpCreateStruct->lpCreateParams;
// Create the splitter window with two columns
if (!m_wndSplitter.CreateStatic(this, 1, 2))
{
TRACE0("Failed to create splitter window\n");
return FALSE;
}
if (!m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CListView),
CSize(175, 0), pContext))
{
m_wndSplitter.DestroyWindow();
return -1;
}
// add the third splitter pane - which is a nested splitter with 2 rows
if (!m_wndSplitter2.CreateStatic(&m_wndSplitter, // our parent window is the first splitter
2, 1, // the new splitter is 2 rows, 1 column
WS_CHILD | WS_VISIBLE | WS_BORDER, // style, WS_BORDER is needed
m_wndSplitter.IdFromRowCol(0, 1))) // new splitter is in the first row, 3rd column of first splitter
{
TRACE0("Failed to create nested splitter\n");
return FALSE;
}
// now create the two views inside the nested splitter
if (!m_wndSplitter2.CreateView(0, 0, RUNTIME_CLASS(CListView),
CSize(0, 100), pContext))
{
m_wndSplitter2.DestroyWindow();
return FALSE;
}
if (!m_wndSplitter2.CreateView(1, 0, RUNTIME_CLASS(CViewManView),
CSize(0, 0), pContext))
{
m_wndSplitter2.DestroyWindow();
return FALSE;
}
m_pViewman=((CViewManView*)m_wndSplitter2.GetPane(1,0));
m_wndSplitter.HideColumn(0);
m_wndSplitter2.HideRow(0);
m_bShowTreeView=FALSE;
m_bShowListView=FALSE;
return 0;
}
void CContainerView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
if( m_wndSplitter.GetSafeHwnd())
{
// move and grow view to clip border
m_wndSplitter.MoveWindow(0,0, cx, cy);
}
}
void CContainerView::HideView()
{
m_wndSplitter2.HideRow(0);
}
void CContainerView::OnInitialUpdate()
{
CView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
CWnd* pWnd=CreateIEView();
if(pWnd)
{
SetActiveView(0);
AddTabItem("请稍候……",pWnd);
}
}
CIEView* CContainerView::CreateIEView()
{
return (CIEView*)m_pViewman->AddView(RUNTIME_CLASS(CIEView));
}
BOOL CContainerView::SetActiveView(int nIndex)
{
return m_pViewman->SetActiveView(nIndex);
}
BOOL CContainerView::DeleteView(int nIndex)
{
return m_pViewman->DeleteView(nIndex);
}
BOOL CContainerView::AddTabItem(LPCTSTR pItem, CWnd *pWnd)
{
return ((CMainFrame*)AfxGetMainWnd())->m_wndTabCtrl.InsertItem(((CMainFrame*)AfxGetMainWnd())->m_wndTabCtrl.GetItemCount(),pItem,pWnd);
}
CIEView* CContainerView::GetAciveView()
{
CView* pView=m_pViewman->GetActiveView();
ASSERT(pView->IsKindOf(RUNTIME_CLASS(CIEView)));
return (CIEView*)pView;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -