// Header file Definition
_ Connectionptr m_pconnection;
_ Recordsetptr m_precordset;
Icroleobjectptr pcroleobj;
Igraphobjectptr pchartobj;
Isectionsptr functions;
Isectionptr ction;
Iparameterfielddefinitionsptr pparamfields;
Iparameterfielddefinitionptr pparamfield;
Ilineobjectptr plineobj;
// CPP implementation
M_application.createinstance (_ uuidof (Application ));
_ Bstr_t strrptname = "E: // cri.pdf // multdetailsexamp // dataandpic. rpt ";
_ Bstr_t strpicname = "E: // criw.// multdetailsexamp // areastudytemp.jpg ";
M_report = m_application-> openreport (_ bstr_t) strrptname );
// Create a report
// M_report = m_application-> newreport ();
// You can directly add images to the Crystal Report and modify the bmp jpg attribute.
Pchartobj = NULL;
Functions = NULL;
Ction = NULL;
Pcroleobj = NULL;
_ Variant_t var;
Variantinit (& var );
Var. Vt = vt_i2;
Var. ival = 1;
// Add an image to a specific area, such as the header file details
Psections = m_report-> getareas ()-> getitem ("D")-> getsections ();
Ction = functions-> getitem (VAR );
Ction-> putname ("test ");
Pcroleobj = direction ction-> addpictureobject (_ bstr_t) strpicname, 0, 0 );
// Modify the position in the image attribute report
Pcroleobj-> name = "Crystal Report test Legend ";
Pcroleobj-> backcolor = RGB (111,111,111 );
Pcroleobj-> left = 1000;
Pcroleobj-> Top = 500;
Pcroleobj-> xscaling = 0.80;
Pcroleobj-> yscaling = 0.80;
// Set the border color and border line
Pcroleobj-> bordercolor = RGB (0,255,255 );
Pcroleobj-> bottomlinestyle = crlssingleline;
Pcroleobj-> toplinestyle = crlssingleline;
Pcroleobj-> rightlinestyle = crlssingleline;
Pcroleobj-> leftlinestyle = crlssingleline;
// For specific attribute settings, refer to the interface attribute description in craxddrt. dll.
// Add parameter data
Pparamfield = m_report-> getparameterfields ()-> getitembyname ("myname ");
Pparamfield-> addcurrentvalue ("hutianyu ");
M_report-> getparameterfields ()-> getitembyname ("mycountry")-> addcurrentvalue ("China ");
// Add a line or rectangle to the area...
Plineobj = ction-> addlineobject (500,400,400,100 0 );
M_report-> saveas ("dataandpictmp. rpt", (crreportfileformat) 0 );
M_wndcrviewer.put_reportsource (m_report );
M_wndcrviewer.viewreport ();
M_wndcrviewer.refresh ();