This lesson is stupid to continue to introduce the application of Chartctrl control in Duilib.
Please review the high four third lesson first.
The method of this lesson is similar to the one in this lesson, because the Chartctrl provides the new tool, so programming can have some simplification.
First, the XML file is exactly the same as the started playing against third lesson.
Second, the CPP file only has the CreateControl part modified, as follows. Of course, the previous Cchartwnd variable is not required.
Virtual ccontrolui* CreateControl (LPCTSTR pstrclassname) { if (_tcsicmp (Pstrclassname, _t ("Wnd")) = = 0) { Cwndui *pui = new Cwndui; HWND hwnd = CreateWindow (_t ("Chartctrl"), _t ("Win32"), Ws_visible | Ws_child | Bs_pushbutton, 0, 0, 0, 0, M_paintmanager.getpaintwindow (), NULL, NULL, NULL); Pui->attach (hWnd); Cchart *chart = Getchart (hWnd); chart->addpoint2d (1, 1); CHART->ADDPOINT2D (2, 2); CHART->ADDPOINT2D (3, 2); CHART->ADDPOINT2D (4, 1); return PUI; } Return Null;return Windowimplbase::createcontrol (pstrclassname); }
As you can see, a Chartctrl window is created directly using CreateWindow, and the third lesson of started playing against IS to create a button window and then glue a cchartwnd.
Effect.
and started playing against the third lesson!!
In terms of code, the two lessons are similar. What are the benefits of the method in this lesson?
Oh, this is a secret, the General people I do not tell him yo!
In fact, the benefit is that the method in this lesson can create multiple windows. In the Cchart version of the current implementation of the stupid, only one window handle can be attach, creating a second window, the attach will fail. Of course, started playing against the eighth lesson can also create multiple windows, but there is a need to write their own window functions, not this lesson so concise.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Cchart Daily Lesson--happy started playing against 14th session Red Apricot, Win32 standard control Chartctrl siege