First, the preface
For the toolbar, I think we must be familiar with, it intuitive, easy to use, it to the application of the user to bring great convenience. For VC + + programmers, the software for their own development to add a toolbar is not difficult, almost every introduction of VC + + books are not to introduce this aspect of the content, and, if you want to join in the early development of the toolbar, it is simpler, MFC can automatically generate toolbars for you. But what we're talking about is a common feature of these toolbars, each of their tool buttons has only one bitmap that visually displays its functionality to the user, and after moving the mouse over a tool button, it quickly pops up a label (tooltips) to indicate its function in text form.
As a Microsoft user, we are most familiar with Microsoft's browser, its toolbar is customizable, you can only display a bitmap on the tool button, and take ToolTips technology, you can also display a bitmap and text labels on the toolbar ("illustrated"). I think if our software also has this function, will it make our software more user-friendly and easy to use? This article details the implementation of the specific steps and give a complete sample project for reference.
Example code run effect diagram
Second, the main function
Let's introduce the implementation of this feature, starting with a couple of related functions:
1. Ctoolbar::setsizes (SIZE sizebutton,size sizeimage)
I do not want to introduce, friends can also guess the function of this function. It is used to set the size of the tool button and the size of the bitmap above it. This function has two parameters, where Sizebutton is used to specify the size of the button, Sizeimage is used to refer to the size of the location graph. Note that both the CX and Cy fields for both parameters must be greater than 0, and that the width of the Sizebutton (CX) is at least 7 greater than the width of the sizeimage and at least 6 of the height (CY).
2. Ctoolbar::setbuttontext (int nindex, LPCTSTR lpsttext)