// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// @doc
// @module MvDocTemplate.cpp |
// This module allow you to use document with multiple views. It
// can be multiple document interface or single document interface.
// @End -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Include file section.
// ------------------------------------------------------------------------
// Precompile header.
#include "stdafx.h"
// Class definition file.
#include "MvDocTemplate.hpp"
// Afx privae include file.
#include <AfxPriv.h>
#define GET_RTCNAME( Object ) Object->GetRuntimeClass()->m_lpszClassName
// @End -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Constructor. Those information are directly passed to the
// base class that will manage the document creation.
CSDIMVDocTemplate::CSDIMVDocTemplate(
UINT _nIDResource,
CRuntimeClass* _pDocClass,
BOOL _bAutoDelete /* = TRUE */ )
: CMvDocTemplate( _nIDResource, _pDocClass, _bAutoDelete )
{
// Init value to prevent error.
m_pDocument = NULL;
}
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
CSDIMVDocTemplate::~CSDIMVDocTemplate( void )
{
}
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Document related method. Those method are needed by the
// sdi concept. To support SDI.
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// This method is called by the CDocTemplate class when opening a
// document. Because we only have 1 docucument we first close the
// one we got, the we set the current to the one we receive in
// parameter.
void CSDIMVDocTemplate::AddDocument( CDocument* _pDoc )
{
// Validate the new document.
if ( !_pDoc )
{
ASSERT ( _pDoc );
TRACE( "Invalid document parameter in the AddDocument method in %s at %d.\n", THIS_FILE, __LINE__ );
return;
}
// Make sure the document is valid.
ASSERT_VALID( _pDoc );
// Call the add document method of our parent class. We don't call the
// multidoc add document because we don't want a multi doc application.
CDocTemplate::AddDocument( _pDoc );
// If a document is already open, we must close it.
if ( m_pDocument )
{
// Already have a document.
// Must close it.
CloseAllDocuments( FALSE );
}
// Store the document pointer for later use.
m_pDocument = _pDoc;
}
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// This method is called by the CDocTemplate class when closing a
// document. Because we only have 1 docucument we only set the
// current one to NULL.
void CSDIMVDocTemplate::RemoveDocument( CDocument* _pDoc )
{
// Validate the document to remove.
if ( !_pDoc )
{
ASSERT ( _pDoc );
TRACE( "Invalid document parameter in the RemoveDocument method in %s at %d.\n", THIS_FILE, __LINE__ );
return;
}
// Since we only got one document to remove, must be the same we keep.
else if ( m_pDocument != _pDoc )
{
// Not the same.
ASSERT( m_pDocument == _pDoc );
TRACE( "Document to remove is not the same as the one we got in the \
RemoveDocument method in %s at %d.\n", THIS_FILE, __LINE__ );
}
// Make sure the document is valid.
ASSERT_VALID( _pDoc );
// Clean the memory.
CleanDocument( _pDoc );
// Call the base class method. Call the CDocTemplate since we manage the doc
// ourselves.
CDocTemplate::RemoveDocument( _pDoc );
// Set the current document to NULL to avoid pointer problem.
m_pDocument = NULL;
}
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// This method is called by the CDocTemplate class when managing
// the document. Because we only have 1 document, we can't return
// the position of the first one. We must return a special ID.
//
// Return: Special id to identify the first document.
POSITION CSDIMVDocTemplate::GetFirstDocPosition( void ) const
{
return ( m_pDocument == NULL ) ? NULL : BEFORE_START_POSITION;
}
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// This method is called by the CDocTemplate class when managing
// the document. Because we only have 1 document, we only return
// the currrent document, depending on the position pass in
// parameter. When returning, we set the current position to NULL,
// because there is no more document in the list.
//
// Return: The document pointer.
CDocument* CSDIMVDocTemplate::GetNextDoc( POSITION& _rPos ) const
{
// Got only 1 document at the same time. We set the next position to
// null. When the framework ask the next document, we will return NULL
CDocument* pReturnDoc = NULL;
// Validate the position requested.
if ( _rPos == BEFORE_START_POSITION )
{
// The position correspond to the first document, our only one.
// Return it.
pReturnDoc = m_pDocument;
}
// The position is invalid.
_rPos = NULL;
return pReturnDoc;
}
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Constructor. Those information are directly passed to the
// base class that will manage the document creation.
CMDIMVDocTemplate::CMDIMVDocTemplate(
UINT _nIDResource,
CRuntimeClass* _pDocClass,
BOOL _bAutoDelete /* = TRUE */)
: CMvDocTemplate( _nIDResource, _pDocClass, _bAutoDelete )
{
}
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
CMDIMVDocTemplate::~CMDIMVDocTemplate( void )
{
}
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// This method is called by the CDocTemplate class when closing a
// document. Must overload to clean the allocated memory associated
// with that document.
void CMDIMVDocTemplate::RemoveDocument( CDocument* _pDoc )
{
// Validate the document to remove.
if ( !_pDoc )
{
ASSERT ( _pDoc );
TRACE( "Invalid document parameter in the RemoveDocument method in %s at %d.\n", THIS_FILE, __LINE__ );
return;
}
// Make sure the document is valid.
ASSERT_VALID( _pDoc );
// Clean the memory.
CleanDocument( _pDoc );
// Call the base class method. Call the CDocTemplate since we manage the doc
// ourselves.
CMultiDocTemplate::RemoveDocument( _pDoc );
}
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Helpfull class to get the document associated document frame manager.
CDocFrameMgr* CMvDocTemplate::GetAssociatedDocFrameMgr( CDocument* _pDoc )
{
POSITION pos = m_DocumentFrameList.GetHeadPosition();
while ( pos )
{
CDocFrameMgr* pDocFrameMgr = m_DocumentFrameList.GetNext( pos );
if ( pDocFrameMgr->GetDocument() == _pDoc )
{
return pDocFrameMgr;
}
}
// Not found.
return NULL;
}
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Constructor. Those information are directly passed to the
// base class that will manage the document creation.
CMvDocTemplate::CMvDocTemplate(
UINT _nIDResource,
CRuntimeClass* _pDocClass,
BOOL _bAutoDelete /* = TRUE */ )
: CMultiDocTemplate( _nIDResource, _pDocClass, NULL, NULL )
{
m_bAutoDelete = _bAutoDelete;
m_pFrameToActivate = NULL;
}
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
CMvDocTemplate::~CMvDocTemplate( void )
{
// Must clean all memory allocated.
while ( m_FrameTemplateList.GetCount() )
没有合适的资源?快使用搜索试试~ 我知道了~
MFC单文档多视图模板类
共4个文件
nfo:1个
hpp:1个
exe:1个
需积分: 5 3 下载量 105 浏览量
2023-09-07
15:02:47
上传
评论 1
收藏 54.48MB RAR 举报
温馨提示
MFC中实现单文档多视图(不同的视图类,且非分割模式)的模板类,使用说明请参阅我的文章。
资源推荐
资源详情
资源评论
收起资源包目录
MFC多视图模板.rar (4个子文件)
MFC多视图模板
多视图模板
MvDocTemplate.hpp 18KB
MvDocTemplate.cpp 30KB
BCG
setup.exe 62.61MB
readme.nfo 3KB
共 4 条
- 1
资源评论
previewer1024
- 粉丝: 80
- 资源: 18
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功