In-depth introduction to CChart daily lesson-Lesson 1 Hello World! No rehearsal for youth in CChart School

Source: Internet
Author: User

Stupid belongs to ordinary people. For this CChart series of tutorials, it cannot be vulgar, but it still starts from HelloWorld. First, a simple example is provided.

The main function of the CChart software library is to draw curves in the software.

CChart is generally used in VC. The stupid development tool is VC6. Although VC6 is very old, although VC6 is not in line with the trend of the times, it is stupid to love her and never change.

If you use a later version of VC, there is no problem. The stupid program has been tested on VS2010 and VS2012, and it is completely normal.

For help, download the cchartdll.7z file from the download channel of www.csdn.net. to ensure the normal operation of the subsequent example program, the CChart version number must be no less than 2.5.1.2. This version is as follows: Click to open the link

Start now!

Step 1: Open VC6.

650) this. width = 650; "alt =" SouthEast "src =" http://img.blog.csdn.net/20130914170110937? Watermark/2/text/plain =/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA =/dissolve/70/gravity/SouthEast "/>

Step 2: Select File --> New, select Win32Application, enter Lesson01 in the Projectname box, and select the appropriate path in the Location box.

650) this. width = 650; "alt =" SouthEast "src =" http://img.blog.csdn.net/20130914170119500? Watermark/2/text/plain =/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA =/dissolve/70/gravity/SouthEast "/>

Step 3: Click OK. In the displayed dialog box, select Atypical "HelloWorld" application, click Finish, and click OK in the next dialog box that appears.

650) this. width = 650; "alt =" SouthEast "src =" http://img.blog.csdn.net/20130914170304125? Watermark/2/text/plain =/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA =/dissolve/70/gravity/SouthEast "/>

650) this. width = 650; "alt =" SouthEast "src =" http://img.blog.csdn.net/20130914170324859? Watermark/2/text/plain =/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA =/dissolve/70/gravity/SouthEast "/>

Step 4: Decompress the cchartdll.7z file and copy all the five files in the Library folder to the folder of the Lesson01 project just created.

650) this. width = 650; "alt =" SouthEast "src =" http://img.blog.csdn.net/20130914170344031? Watermark/2/text/plain =/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA =/dissolve/70/gravity/SouthEast "/>

Step 5: Open the Lesson01.cpp file in VC and enter the following code under the line # defineMAX_LOADSTRING100 in the file header.

# Include "Chart. h"
# Ifdef_DEBUG
# Pragmacomment (lib, "PlotDll_d.lib ")
# Else
# Pragmacomment (lib, "PlotDll. lib ")
# Endif

This is what everyone understands: header files and Import and Export files.

Step 6: Find the WndProc function of the Lesson01.cpp file and enter the following code in the original LoadString (hInst, IDS_HELLO, szHello, MAX_LOADSTRING.

StaticCChartWndchartWnd;

Step 7: Find the caseWM_PAINT row in the WndProc function and enter the following code on it.

CaseWM_CREATE:
ChartWnd. Attach (hWnd, kTypeXY );

ChartWnd. GetChart ()-> AddPoint2D (-3.0, 9.0 );
ChartWnd. GetChart ()-> AddPoint2D (-2.0, 4.0 );
ChartWnd. GetChart ()-> AddPoint2D (-1.0, 1.0 );
ChartWnd. GetChart ()-> AddPoint2D (0.0, 0.0 );
ChartWnd. GetChart ()-> AddPoint2D (1.0, 1.0 );
ChartWnd. GetChart ()-> AddPoint2D (2.0, 4.0 );
ChartWnd. GetChart ()-> AddPoint2D (3.0, 9.0 );

ChartWnd. GetChart ()-> SetTitle (_ T ("HelloWorld, my first CChart program! "));
Break;

Step 8: Find caseWM_DESTROY in the WndProc function: Add a row under it.

chartWnd.Detach();

Step 9: Find caseWM_PAINT in the WndProc function: delete a row, or comment out the following code.

CaseWM_PAINT:
Hdc = BeginPaint (hWnd, & ps );
// TODO: Addanydrawingcodehere...
RECTrt;
GetClientRect (hWnd, & rt );
DrawText (hdc, szHello, strlen (szHello), & rt, DT_CENTER );
EndPaint (hWnd, & ps );
Break;

Step 10: Compile and run the program.

650) this. width = 650; "alt =" SouthEast "src =" http://img.blog.csdn.net/20130914194712203? Watermark/2/text/plain =/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA =/dissolve/70/gravity/SouthEast "/>

Summary: In the first lesson, we used the CChart function to connect the seven points into a curve and draw it easily.

Class now

Related Article

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.