📄 dongtaireport.cpp
字号:
// DongTaiReport.cpp : implementation file
//
#include "stdafx.h"
#include "falcon_jxc.h"
#include "DongTaiReport.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CString m_sReportFile="";
/////////////////////////////////////////////////////////////////////////////
// CDongTaiReport dialog
static const char BASED_CODE mFilter[] = "Crystal Reports|*.rpt||";
CDongTaiReport::CDongTaiReport(CWnd* pParent /*=NULL*/)
: CDialog(CDongTaiReport::IDD, pParent)
{
//{{AFX_DATA_INIT(CDongTaiReport)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_bApp=false;
}
void CDongTaiReport::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDongTaiReport)
DDX_Control(pDX, IDC_CRVIEWER1, m_PreviewReport);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDongTaiReport, CDialog)
//{{AFX_MSG_MAP(CDongTaiReport)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDongTaiReport message handlers
BOOL CDongTaiReport::OnInitDialog()
{
if(m_sReportFile!="")
{
CDialog::OnInitDialog();
CFileDialog FileOpenDlg(TRUE,"*.rpt",NULL, OFN_EXPLORER, mFilter);
int iResult = FileOpenDlg.DoModal();
if(iResult == IDOK)
{
//取得所选择的文件名
_bstr_t OpenFileName(FileOpenDlg.GetPathName().AllocSysString());
m_Application.CreateInstance("CrystalDesignRuntime.Application");
//打开报表
m_Report = m_Application->OpenReport(OpenFileName);
m_sReportFile=FileOpenDlg.GetPathName();
SysFreeString(OpenFileName);
// m_PreviewReport.RefreshEx(false);
m_PreviewReport.SetReportSource(m_Report);
//设置报表预览的放大比例
// m_PreviewReport.Zoom(1);
// m_PreviewReport.Refresh();
//在Viewer控件中先显示报表
m_PreviewReport.ViewReport();
m_bApp=true;
/*/-------------------------------------------------------------------------
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;
*///-------------------------------------------------------------------------
}
else if (iResult == IDCANCEL)
{
return false;
}
return TRUE;
}
else
{
CDialog::OnInitDialog();
CFileDialog FileOpenDlg(TRUE,"*.rpt",NULL, OFN_EXPLORER, mFilter);
int iResult = FileOpenDlg.DoModal();
if(iResult == IDOK)
{
//取得所选择的文件名
_bstr_t OpenFileName(FileOpenDlg.GetPathName().AllocSysString());
m_Application.CreateInstance("CrystalDesignRuntime.Application");
//打开报表
m_Report = m_Application->OpenReport(OpenFileName);
m_sReportFile=FileOpenDlg.GetPathName();
m_PreviewReport.RefreshEx(false);
m_PreviewReport.SetReportSource(m_Report);
//设置报表预览的放大比例
// m_PreviewReport.Zoom(1);
m_PreviewReport.Refresh();
//在Viewer控件中先显示报表
m_PreviewReport.ViewReport();
m_bApp=true;
// SysFreeString(OpenFileName);
}
else if (iResult == IDCANCEL)
{
return false;
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
}
/*
BOOL CDongTaiReport::DestroyWindow()
{
// TODO: Add your specialized code here and/or call the base class
// if(m_sReportFile!="")
//
// m_PreviewReport.DestroyWindow();
// m_Report.Release();
// m_Application.Release();
// m_Application.Release();
return CDialog::DestroyWindow();
}
*/
void CDongTaiReport::OnButton1()
{
// TODO: Add your control notification handler code here
CDialog::DestroyWindow();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -