|
// CReportCRDesigner.cpp : implementation file
//
#include "stdafx.h"
#include "CR10Test.h"
#include "ReportCRDesigner.h"
static const char BASED_CODE szFilter[] = "Crystal Reports|*.rpt||";
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CReportCRDesigner dialog
CReportCRDesigner::CReportCRDesigner(CWnd* pParent /*=NULL*/)
: CDialog(CReportCRDesigner::IDD, pParent)
{
//{{AFX_DATA_INIT(CReportCRDesigner)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CReportCRDesigner::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CReportCRDesigner)
DDX_Control(pDX, IDC_SAVE_REPORT, pBtSaveReport);
DDX_Control(pDX, IDC_SHOW_DESIGNER, pBtDesigner);
DDX_Control(pDX, IDC_PREVIEW, pBtPrivew);
DDX_Control(pDX, IDC_OPEN_REPORT, pBtOpenReport);
DDX_Control(pDX, IDC_NEW_REPORT, pBtNewReport);
DDX_Control(pDX, IDC_EMBEDDABLECRYSTALREPORTSDESIGNERCTRL1, pCtrlReportDesigner);
DDX_Control(pDX, IDC_ACTIVEXREPORTVIEWER1, pCtrlReportViewer);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CReportCRDesigner, CDialog)
//{{AFX_MSG_MAP(CReportCRDesigner)
ON_BN_CLICKED(IDC_NEW_REPORT, OnNewReport)
ON_BN_CLICKED(IDC_OPEN_REPORT, OnOpenReport)
ON_BN_CLICKED(IDC_SAVE_REPORT, OnSaveReport)
ON_BN_CLICKED(IDC_PREVIEW, OnPreview)
ON_BN_CLICKED(IDC_SHOW_DESIGNER, OnShowDesigner)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CReportCRDesigner message handlers
BOOL CReportCRDesigner::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
pCtrlReportViewer.ShowWindow(SW_HIDE);
pCtrlReportDesigner.ShowWindow(SW_SHOW);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CReportCRDesigner::InitReport(BOOL bNew)
{
CLSID CLSID_Application;
CLSIDFromProgID(L"CrystalDesignRunTime.Application.10", &CLSID_Application);
HRESULT hr = CoCreateInstance(CLSID_Application, NULL, CLSCTX_INPROC_SERVER , __uuidof(IApplication), (void **) &m_Application);
ASSERT(SUCCEEDED(hr));
if(bNew)
{
m_Report = m_Application->NewReport();
}
else
{
CFileDialog FileDlg(TRUE,"*.rpt",NULL, OFN_EXPLORER, szFilter);
int iReturn = FileDlg.DoModal();
if(iReturn == IDOK)
{
_bstr_t FileName(FileDlg.GetPathName().AllocSysString());
m_Report = m_Application->OpenReport(FileName);
}
else if (iReturn = IDCANCEL)
{
return;
}
}
pCtrlReportDesigner.SetReportObject(m_Report);
pCtrlReportViewer.SetReportSource(m_Report);
pCtrlReportViewer.Zoom(1);
pCtrlReportViewer.ViewReport();
if(!pCtrlReportDesigner.IsWindowVisible())
{
pBtDesigner.ShowWindow(SW_HIDE);
pBtPrivew.ShowWindow(SW_SHOW);
pCtrlReportViewer.ShowWindow(FALSE);
pCtrlReportDesigner.ShowWindow(TRUE);
}
}
void CReportCRDesigner::OnNewReport()
{
// TODO: Add your control notification handler code here
InitReport(TRUE);
}
void CReportCRDesigner::OnOpenReport()
{
// TODO: Add your control notification handler code here
InitReport(FALSE);
}
void CReportCRDesigner::OnSaveReport()
{
// TODO: Add your control notification handler code here
CFileDialog FileDlg(FALSE,"*.rpt",NULL,OFN_EXPLORER, szFilter);
int iReturn = FileDlg.DoModal();
if(iReturn == IDOK)
{
_bstr_t FileName(FileDlg.GetPathName().AllocSysString());
pCtrlReportDesigner.SaveReport(FileName);
}
else if(iReturn == IDCANCEL)
{
return;
}
}
void CReportCRDesigner::OnPreview()
{
// TODO: Add your control notification handler code here
pBtPrivew.ShowWindow(SW_HIDE);
pBtDesigner.ShowWindow(SW_SHOW);
pCtrlReportViewer.RefreshEx(FALSE);
pCtrlReportDesigner.ShowWindow(SW_HIDE);
pCtrlReportViewer.ShowWindow(SW_SHOW);
}
void CReportCRDesigner::OnShowDesigner()
{
// TODO: Add your control notification handler code here
pBtDesigner.ShowWindow(SW_HIDE);
pBtPrivew.ShowWindow(SW_SHOW);
pCtrlReportViewer.ShowWindow(SW_HIDE);
pCtrlReportDesigner.ShowWindow(SW_SHOW);
}
|
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.