Click here to Skip to main content
15,885,546 members
Articles / Desktop Programming / MFC

Using a Doc/View exported from a dynamically loaded DLL

Rate me:
Please Sign up or sign in to vote.
4.95/5 (13 votes)
15 Nov 2001CPOL3 min read 116.2K   7.1K   79  
An article on on how to load DLLs which export doc/views.
// DocViewFromDLLView.cpp : implementation of the CDocViewFromDLLView class
//

#include "stdafx.h"
#include "DocViewFromDLL.h"

#include "DocViewFromDLLDoc.h"
#include "DocViewFromDLLView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDocViewFromDLLView

IMPLEMENT_DYNCREATE(CDocViewFromDLLView, CFormView)

BEGIN_MESSAGE_MAP(CDocViewFromDLLView, CFormView)
	//{{AFX_MSG_MAP(CDocViewFromDLLView)
		// 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
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDocViewFromDLLView construction/destruction

CDocViewFromDLLView::CDocViewFromDLLView()
	: CFormView(CDocViewFromDLLView::IDD)
{
	//{{AFX_DATA_INIT(CDocViewFromDLLView)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// TODO: add construction code here

}

CDocViewFromDLLView::~CDocViewFromDLLView()
{
}

void CDocViewFromDLLView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDocViewFromDLLView)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BOOL CDocViewFromDLLView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CFormView::PreCreateWindow(cs);
}

void CDocViewFromDLLView::OnInitialUpdate()
{
	CFormView::OnInitialUpdate();
	ResizeParentToFit();

}

/////////////////////////////////////////////////////////////////////////////
// CDocViewFromDLLView printing

BOOL CDocViewFromDLLView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CDocViewFromDLLView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CDocViewFromDLLView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

void CDocViewFromDLLView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
	pDC->TextOut(0, 0, "EXECUTABLE document view print output") ;
}

/////////////////////////////////////////////////////////////////////////////
// CDocViewFromDLLView diagnostics

#ifdef _DEBUG
void CDocViewFromDLLView::AssertValid() const
{
	CFormView::AssertValid();
}

void CDocViewFromDLLView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}

CDocViewFromDLLDoc* CDocViewFromDLLView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDocViewFromDLLDoc)));
	return (CDocViewFromDLLDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CDocViewFromDLLView message handlers

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Sirius Analytical Instruments
United Kingdom United Kingdom
A research and development programmer working for a pharmaceutical instrument company for the past 17 years.

I am one of those lucky people who enjoys his work and spends more time than he should either doing work or reseaching new stuff. I can also be found on playing DDO on the Cannith server (Send a tell to "Maetrim" who is my current main)

I am also a keep fit fanatic, doing cross country running and am seriously into [url]http://www.ryushinkan.co.uk/[/url] Karate at this time of my life, training from 4-6 times a week and recently achieved my 1st Dan after 6 years.

Comments and Discussions