有没有一些类库提供画图的接口的,画一些函数曲线和统计图表,如直方图等?
解决方案 »
- 关于“2010年我34岁了,大家给我祝福吧”帖子的可用分发放
- 请推荐一本关于完成端口编程的书籍
- 系统提示"所需资源不可用"是什么原因?
- vc6 到vc2005的移植问题
- 竭尽全分求解!我的最后100分!!使用哈希表技术判断两个源程序的相似性!!!
- 求教高手:大师级的,Microsoft FlexGrid控件的问题。
- 知道一个当前节点,能不能得到这棵树的根节点呢?
- 想做一个spy串口的监视程序,请大家提点建议!
- 语音聊天的流程!
- 高价收购屏幕取词原码,偶实在没有办法了。
- 文件对话框初始路径问题(m_ofn.lpstrInitialDir)
- 怎么在自己的应用程序中加入代码让别人的应用程序的窗口处于最前端被激活的状态,而且鼠标不响应自己的应用程序
There are different ways to access the Report Designer Component (RDC) and any other COM Automation server through Visual C++. This section describes how to use the #import method.Manipulating the RDC in Microsoft Visual C++ involves three steps:Define and instantiate a variable to be used to manipulate the RDC COM object. Instantiate an actual instance of the RDC COM object and assign it to a variable. Manipulate the Properties and Methods and then output the report.
The following section leads you through the details in each of these steps.Printing a Report through Visual C++
To print a report through Visual C++
Open Visual C++ 6.0 if it isn't already running. On the File menu, select New. In the New dialog box, select the MFC AppWizard (exe) from the Projects tab. Type MyRDC for the Project Name and click OK. In the first step of the wizard, select Dialog based and click Finish to accept the defaults for the MFC AppWizard, and then click OK in the New Project Information dialog box. When the wizard executes, a dialog box appears in design mode.Right-click the dialog box and select Insert ActiveX Control from the popup dialog box. From the list of available controls, select Crystal Report Viewer Control. Resize the control to the desired size. Rearrange the OK and Cancel buttons to their desired location. Select the View|Class Wizard. Click the Member Variables tab and ensure that the class name is CMyRDCDlg. Add a variable for the IDC_CRVIEWER1 and click OK when prompted to add the control to the project. Name the member variable for the viewer m_Viewer. Click OK to save the changes and then close the dialog box. Add a reference to the RDC runtime object Model. On the File|Open menu, select the MyRDCdlg.h file that was generated by the MFC App wizard and click Open. On the File|Open menu, open the MyRDC.CPP file and add the following code before the message map: struct InitOle {
InitOle() { ::CoInitialize(NULL); }
~InitOle() { ::CoUninitialize(); }
} _init_InitOle_;
Declare protected member variables for the RDC's Application and Report objects in the implementation section of the MyRDCdlg.h header file. For optional Variant parameters declare a protected dummy variable in the same section.IApplicationPtr m_Application;
IReportPtr m_Report;
VARIANT dummy;
Add the following constants after the #endif statement in the declarations section of the MyRDCdlg.CPP file.
// The constants needed to create the Application and Report Objects COM objects
const CLSID CLSID_Application = {0xb4741fd0,0x45a6,0x11d1,{0xab,0xec,0x00,0xa0,0xc9,0x27,0x4b,0x91}};
const IID IID_IApplication = {0x0bac5cf2,0x44c9,0x11d1,{0xab,0xec,0x00,0xa0,0xc9,0x27,0x4b,0x91}};
const CLSID CLSID_ReportObjects = {0xb4741e60,0x45a6,0x11d1,{0xab,0xec,0x00,0xa0,0xc9,0x27,0x4b,0x91}};
const IID IID_IReportObjects = {0x0bac59b2,0x44c9,0x11d1,{0xab,0xec,0x00,0xa0,0xc9,0x27,0x4b,0x91}};
Also in the MyRDCdlg.CPP file, add the following code to the CMyRDCDlg::OnInitDialog() method just before the return statement:
// A dummy variant
VariantInit (&dummy);
dummy.vt = VT_EMPTY;
HRESULT hr = S_OK;
IApplicationPtr m_Application = NULL;
IReportPtr m_Report = NULL;
// Specify the path to the report you want to print
_bstr_t ReportPath("c:\\Program Files\\Crystal Decisions\\Crystal Reports 9\\Samples\\En\\Reports\\General Business\\Inventory.rpt");
_variant_t vtEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);// Instantiate the IApplication object
hr = CoCreateInstance(CLSID_Application, NULL, CLSCTX_INPROC_SERVER , IID_IApplication, (void **) &m_Application);//Open the Report using the OpenReport method
m_Report = m_Application->OpenReport(ReportPath, dummy);//Print the Report to window
m_Viewer.SetReportSource(m_Report);
m_Viewer.ViewReport();
Finally, on the Build menu, select Rebuild All, then Execute. When the app runs, it opens the report and displays it in the viewer control on the application's dialog. Click OK or Cancel to dismiss the dialog and terminate the application.Opening and Printing a Crystal Report through the RDC
To open and print a Crystal Report through the RDC
On the File|Open menu, open the MyRDC.CPP file. Add the following code to the MyRDC.InitInstance() method just before the return statement:
// A dummy variant
VariantInit (&dummy);
dummy.vt = VT_EMPTY;
HRESULT hr = S_OK;
IApplicationPtr m_Application = NULL;
IReportPtr m_Report = NULL;// Specify the path to the report you want to print
_bstr_t ReportPath("c:\\Program Files\\Crystal Decisions\\Crystal Reports 9 \\Samples\\En\\Reports\\General Business\\Inventory.rpt");
_variant_t vtEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);
// Instantiate the IApplication object
hr = CoCreateInstance(CLSID_Application, NULL, CLSCTX_INPROC_SERVER , IID_IApplication, (void **) & CRAXDRT::IApplication);
//Open the Report using the OpenReport method
m_Report = m_Application->OpenReport(ReportPath, dummy)
//Print the Report to printer
m_Report->PrintOut(dummy, dummy, dummy, dummy
);
Finally, on the Build menu, select Rebuild All.
There are hundreds of properties, methods, and events in the Report Designer Component object model that you can manipulate through your code to meet the demands of virtually any reporting requirement.