splitdoc.cpp

来自「这是一个VC++的程序员实用大全精华版」· C++ 代码 · 共 108 行

CPP
108
字号
// SplitDoc.cpp : implementation of the CSplitDoc class
//

#include "stdafx.h"
#include "Split.h"

#include "SplitDoc.h"
#include	"MainFrm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSplitDoc

IMPLEMENT_DYNCREATE(CSplitDoc, CDocument)

BEGIN_MESSAGE_MAP(CSplitDoc, CDocument)
	//{{AFX_MSG_MAP(CSplitDoc)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSplitDoc construction/destruction

CSplitDoc::CSplitDoc()
{
	// TODO: add one-time construction code here

}

CSplitDoc::~CSplitDoc()
{
}

BOOL CSplitDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

    CMainFrame *frame = DYNAMIC_DOWNCAST(CMainFrame, AfxGetApp()->GetMainWnd());
	if (frame == NULL)
		((CEditView*)m_viewList.GetHead())->SetWindowText(NULL);
	else
	{
		frame->SetActiveView ((CView *)frame->m_Primary);
		((CEditView*)frame->m_Primary)->SetWindowText(NULL);
	}

	// TODO: add reinitialization code here
	// (SDI documents will reuse this document)

	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CSplitDoc serialization

void CSplitDoc::Serialize(CArchive& ar)
{
	// CEditView contains an edit control which handles all serialization
    CMainFrame *frame = DYNAMIC_DOWNCAST(CMainFrame, AfxGetApp()->GetMainWnd());
	if (frame == NULL)
		((CEditView*)m_viewList.GetHead())->SerializeRaw(ar);
	else
		((CEditView*)frame->m_Primary)->SerializeRaw(ar);

}

/////////////////////////////////////////////////////////////////////////////
// CSplitDoc diagnostics

#ifdef _DEBUG
void CSplitDoc::AssertValid() const
{
	CDocument::AssertValid();
}

void CSplitDoc::Dump(CDumpContext& dc) const
{
	CDocument::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CSplitDoc commands

BOOL CSplitDoc::OnOpenDocument(LPCTSTR lpszPathName) 
{
    CMainFrame *frame = DYNAMIC_DOWNCAST(CMainFrame, AfxGetApp()->GetMainWnd());
	if (frame != NULL)
	{
		frame->SetActiveView ((CView *)frame->m_Primary);
	}

	if (!CDocument::OnOpenDocument(lpszPathName))
		return FALSE;
	
	// TODO: Add your specialized creation code here
	
	return TRUE;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?