Add a text label to the VC + + toolbar button

Source: Internet
Author: User

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)

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.