As we all know, a workbook in Excel can have more than one work form (worksheet), and each form can be controlled flexibly by a label in the lower left corner (see figure I), and Visual C + + has similar controls, such as setting in the Output window: Build,debug, Find in files and results, such as Label control (figure II).
Figure one Label control in Excel
Figure II Label control in Visual C + +
We refer to this interface as the label control of the folder style, hereinafter referred to as the label control, and in MFC, the tab control is called the label controls. So how is the label control implemented? Are there any out-of-the-box controls available in MFC?
Many people in the forum have raised this question. After reading this article, I think this question should have a satisfactory answer. MFC is very convenient for programming, but it can not replace the programmer's programming, MFC just provides a programming framework, the application of the substantive code or must be written by the programmer. At the same time, MFC's problem is also obvious, that is, its GUI material is too rich, so that programmers are too dependent on MFC, when you want to implement the GUI features of MFC does not feel overwhelmed.
Let's take a look at how to implement the Label control interface for the folder styles shown in Figure I and figure two. One might think of starting with the ready-made Label controls (tab control). But experience has shown that this approach is not to be used for convenience and better reusability. I'm a big fan of reusability, but we don't do enough in our code. So I'd rather create a window class myself, and there's a benefit that you can completely control the changes in your code without having to take into account the huge impact and hassle of your own code as a result of the changes in the existing control version. I think the guy at Microsoft would have wanted you to do the same. If you use Spy + + to view the interface between Excel and Visual C + +, you will find that the label control of its folder style is not systabcontrol32s, but a separate window class created. Why don't we also create one?
Please look at the picture shown in figure three, this is a program I wrote Fldrtab, it implements the interface function we want. The C + + class that implements this UI is created by myself, it's called Cfoldertabctrl.
Figure three Fldrtab program running picture