multiviewreportdoc.cpp

来自「一个很好用的报表控件」· C++ 代码 · 共 133 行

CPP
133
字号
// MultiViewReportDoc.cpp : implementation of the CMultiViewReportDoc class
//

#include "stdafx.h"
#include "MultiViewReport.h"

#include "MultiViewReportDoc.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMultiViewReportDoc

IMPLEMENT_DYNCREATE(CMultiViewReportDoc, CDocument)

BEGIN_MESSAGE_MAP(CMultiViewReportDoc, CDocument)
	//{{AFX_MSG_MAP(CMultiViewReportDoc)
		// 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()

/////////////////////////////////////////////////////////////////////////////
// CMultiViewReportDoc construction/destruction

CMultiViewReportDoc::CMultiViewReportDoc():iReport(NULL)
{
	// TODO: add one-time construction code here
}

CMultiViewReportDoc::~CMultiViewReportDoc()
{
	if(iReport != 0)
        iReport->Release();
}

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

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

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CMultiViewReportDoc serialization

void CMultiViewReportDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// TODO: add storing code here
	}
	else
	{
		// TODO: add loading code here
	}
}

/////////////////////////////////////////////////////////////////////////////
// CMultiViewReportDoc diagnostics

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

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

/////////////////////////////////////////////////////////////////////////////
// CMultiViewReportDoc commands

BOOL CMultiViewReportDoc::OnOpenDocument(LPCTSTR lpszPathName) 
{
	if (!CDocument::OnOpenDocument(lpszPathName))
		return FALSE;
	
	// TODO: Add your specialized creation code here
	CMultiViewReportApp * Application = (CMultiViewReportApp *)AfxGetApp();
    IApplication * iApplication = Application->GetAutoApplication();
    ASSERT(iApplication != NULL);
    ASSERT(iReport == NULL);

	VARIANT var;
    var.vt = VT_I2;
    var.iVal = 0;

    CString theString = lpszPathName;
	BSTR bstr = theString.AllocSysString  ();
    HRESULT hr = iApplication->OpenReport (bstr, var, &iReport);
    if(hr != NOERROR)
    {
        CMultiViewReportApp::ProcHandleError(hr);
        return FALSE;
    }
	
    SysFreeString(bstr);

	return TRUE;
}

BOOL CMultiViewReportDoc::OnSaveDocument(LPCTSTR lpszPathName) 
{
	// TODO: Add your specialized code here and/or call the base class
	ASSERT(iReport != 0);
    CString thisString = lpszPathName;
	BSTR bstr = thisString.AllocSysString  ();
    HRESULT hr = iReport->Save(bstr);
    SysFreeString(bstr);

    if(hr != NOERROR)
    {
        CMultiViewReportApp::ProcHandleError(hr);
        return FALSE;
    }    
	
	return CDocument::OnSaveDocument(lpszPathName);
}

⌨️ 快捷键说明

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