Welcome Guest.


How to import pictures in teechart control in VC

Asked by: Jeffrey Patel 283 views IT September 1, 2018

How to import images and saved excel in VC's teechart control, the code is in front of it, and later, ask the old irons to answer

 LPCSTR szFilter = "image format (*.jpg) |*.jpg|Data Format (*.xls)|*.xls|All Files(*.*)|*.*||"; CFileDialog dlg(TRUE,"jpg","", OFN_OVERWRITEPROMPT, szFilter); / / jpg is the role is not specified when the file save type, the default is the jpg suffix name,   / / " " inside the default is not added to the file name, generally do not.  if(IDCANCEL == dlg.DoModal())  return; CString szFile = dlg.GetPathName(); CString FT= dlg.GetFileExt(); CFile file;   If(!file.Open(szFile,CFile::modeRead|CFile::shareDenyNone)) {  AfxMessageBox("Failed to open file!");  return; }

1 Answers

  1. +4Votes  

    TeeChart export BMP, WMF

    TeeChart provides a method for exporting BMP and WMF, which can be called directly. The example is as follows:

    Chart1.SaveToBitmapFile(‘c:\1.bmp ‘);



    TeeChart export JPG (JPEG) is also relatively simple, use TeeJPEG unit in this unit, and then execute TeeSaveToJPEG or TeeSaveToJPEGFile in TeeJPEG. Here’s an example:

    //Note that you should include TeeJPEG

    implementationuses  TeeJPEG;

    procedureTForm1.Button2Click(Sender: TObject);

    begin  TeeSaveToJPEG(Chart1, ‘c:\1.jpg’, -1, -1);

    //The two parameters behind are width and height, if using TeeChart’s width , height can be set to -1.end;

    TeeChart export GIF is more complicated, code example:

    //Note to include TeeGIF Only implementationss  TeeGIF;procedureTForm1.Button3Click(Sender: TObject);

    var  exp : TGIFExportFormat;  

    frm : TTeeGIFOptions;begin  exp := TGIFExportFormat .Create;

    exp.Panel := Chart1;  

    frm := TTeeGIFOptions(exp.Options());  

    frm.CBReduction .ItemIndex := 3;  





    Note: The above example is very representative for the image export of TeeChart. In fact, all formats can be exported to the above example, just replace TGIFExportFormat with The format you need is Yes, because all exports correspond to one format.

    In the above example, generate an exported format class object, set the Chart to be exported in this format, and set the exported options if necessary. The export option should be specially reminded that the export options for all export formats are set by the form obtained by the Options() function of the format class. This is strange.

    GIF export must set frm.CBReduction.ItemIndex, because this item defaults to 0, it will report “Color Table error….” error when exporting, so it must be set to a value other than 0. What do each value mean? You can check it out.

    TeeChart exporting PCX is very similar to exporting GIF. The code example is as follows:

    //Note that you should include TeePCX to implementationuses  TeePCX; procedureTForm1.Button4Click(Sender: TObject);

    var  exp : TPCXExportFormat;

    begin  exp := TPCXExportFormat.Create;  

    exp .Panel := Chart1;  





    TeeChart export HTM

    TeeChart can be directly exported to HTM, use TeeVMLCanvas unit in this unit, then execute TeeSaveToVMLFile in TeeVMLCanvas . Here’s an example:

    //Note that you should include TeeVMLCanvas

    implementationuses  TeeVMLCanvas;

    procedureTForm1.Button5Click(Sender: TObject);

    begin  TeeSaveToVMLFile(Chart1, ‘c:\1.html’);


    TeeChart can be easily Export to PNG, use TeePNG unit in this unit, and then execute TeeSaveToPNG in TeePNG. Here’s an example:

    //Note that you should include TeePNG

    implementationuses  TeePNG;

    procedureTForm1.Button7Click(Sender: TObject);

    begin  TeeSaveToPNG(Chart1, ‘c:\1.png’);


    Note: Save PNG The format requires LPng.dll, so in order to run the above example code, you need to download and install LPng.dll.

    Carol Cooper- September 2, 2018 |