Add images directly to the Crystal Report in VC

Source: Internet
Author: User
Tags border color

// 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 ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.