Next, use VC6 to open the program written in Lesson 1 and run it. The interface shown in the last figure of Lesson 1 appears.
Move the mouse around in the window of the program. Does the image state change with the moving of the mouse position?
Yes, that is, the interaction function of CChart is working.
The strange thing is that we didn't add any code for the interaction function !!!
To fully experience the interaction function of CChart, You Need To slightly modify the program of Lesson 1.
Open the Lesson01.cpp file in VC, find the ATOMMyRegisterClass (HINSTANCEhInstance) function, and find the following line in the function.
wcex.style= CS_HREDRAW | CS_VREDRAW;
Modify this line to the following.
wcex.style= CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
The reason for the modification is that the program automatically generated by the Win32Application Wizard of VC does not respond to double-clicking the mouse by default. The above modification allows our program to respond to double-clicking the mouse.
Is it easy? Do I need to write code below?
I really don't need it. The code for this lesson is written till now.
The interaction function of CChart is briefly introduced below.
3.1 interaction objects
The interaction objects in CChart are called elements. The specific ranges of elements include the image title, drawing area, curve, coordinate axis, and legend.
To explain the above elements, we first display the legend.
Right-click the client area of the program and choose the right-click menu.
650) this. width = 650; "src =" http://img.blog.csdn.net/20130915001043359? Watermark/2/text/plain =/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA =/dissolve/70/gravity/SouthEast "alt =" SouthEast "/>
Click "ShowLegend". The program interface is shown below.
650) this. width = 650; "src =" http://img.blog.csdn.net/20130915001055750? Watermark/2/text/plain =/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA =/dissolve/70/gravity/SouthEast "alt =" SouthEast "/>
Haha, the legend is displayed.
You can modify the program interface to display the elements. The modification method is not to modify the code, but to use the interaction function to directly change the code when the program is running. Students will change the code later.
650) this. width = 650; "src =" http://img.blog.csdn.net/20130915001147921? Watermark/2/text/plain =/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA =/dissolve/70/gravity/SouthEast "alt =" SouthEast "/>
3.2 element highlighting
When you hover the mouse over a graph element, the element is highlighted.
Highlight the image title.
650) this. width = 650; "src =" http://img.blog.csdn.net/20130915001340437? Watermark/2/text/plain =/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA =/dissolve/70/gravity/SouthEast "alt =" SouthEast "/>
For coordinate axis highlight, curve highlight, data area highlight, and legend highlight, we will not demonstrate it here. You can see the effect by moving your mouse.
You can think about how to highlight image titles, axes, and other elements. It is not difficult to implement them because they are just boxes. But isn't it that easy to highlight curves? This is a stupid and dedicated stunt. I have a full source code version of CChart ON THE CSDN download channel. If anyone is interested in how to highlight the curve, download it.
3.3 select elements
Image titles, axes, and curves can be selected.
When you place the cursor over an element, you can select it by clicking the left mouse button. You can also left-click the curve in the legend.
The page displayed after the curve is selected. The line width increases and the color changes. Of course, there is no difference in comparison.
650) this. width = 650; "src =" http://img.blog.csdn.net/20130915001440171? Watermark/2/text/plain =/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA =/dissolve/70/gravity/SouthEast "alt =" SouthEast "/>
3.4 select switch
The Space key is used to switch the selection of elements. Press the Space key to switch the selection according to the sequence of title> AXIS> data curve> title. Multiple Axes and multiple data curves are switched according to the order they are added.
You can try it by pressing the Space key.
3.5 edit Elements
When an element is selected, press Enter to bring up a dialog box that allows you to edit the attributes of the element.
For example, if the curve is selected, press enter to display the following dialog box.
650) this. width = 650; "src =" http://img.blog.csdn.net/20130915001527906? Watermark/2/text/plain =/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA =/dissolve/70/gravity/SouthEast "alt =" SouthEast "/>
In this dialog box, you can modify many attributes of an element. For example, change the Title to "new data of CChart" and press OK to modify the image interface accordingly.
650) this. width = 650; "src =" http://img.blog.csdn.net/20130915001529171? Watermark/2/text/plain =/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA =/dissolve/70/gravity/SouthEast "alt =" SouthEast "/>
In the legend, the text in the legend is the title of the curve. If there are multiple curves, each curve has a title.
In addition to the Enter key, you can double-click the button to bring up the Properties dialog box.
3.6 right-click menu
Right-click the menu at the beginning of this lesson and use the right-click menu to bring up the legend.
In fact, the right-click menu has rich functions. You can give it a try and see the functions and effects of each menu.
Well, the next lesson bell rings, and the content of this lesson is quite rich, but only half of the Code is actually written. In fact, this half-sentence code can also be left empty. The effect on the function is that double-clicking the mouse does not work. You cannot be stupid about this problem. If you want to blame it, go to Bill Gates.
These two courses are basically nonsense, and some dry work will be prepared at the beginning of the next lesson.