MFC uses ChartCtrl to draw curves

MFC uses ChartCtrl to draw curves

Add ChartCtrl library

The ChartCtrl library needs to be downloaded from the Internet. The download address provided here is the entire project, which contains the ChartCtrl library. Copy the entire ChartCtrl folder to the working path, as shown in the following figure:

Right-click in the project and select Add Existing Project to add the files in the entire folder to the project:

Add the header file in h in dlg:

So far, the ChartCtrl library has been added to our project.

Implement ChartCtrl drawing

First, add the control Custom Control in the interactive interface, and modify the relevant parameters. The main thing is that the Class should be ChartCtrl, and the ID should be named by itself. It will be used later, and the Style should be changed to 0x52010000:

Define a CChartCtrl class in .h and bind it to the control ID in .cpp:

When the .cpp dialog box is initialized, initialize the ChartCtrl control, and set the title, abscissa name, and ordinate name of the curve:

In the button event, realize the display of the curve:

The final display effect is as follows (the second curve is created in another way):

https://download.csdn.net/download/zhoufm260613/12584583

Guess you like

Origin blog.csdn.net/zhoufm260613/article/details/107520350