A simple method to add tooltip for the MFC-based dialog box

Source: Internet
Author: User

This method is applicable to the MFC derived class and passed the test in the dialog box-based class. The procedure is as follows:

 

1. Select the "project" menu and then "set active project ".

2. Select "project" menu --> "add to project" --> "components and controls" --> "VC ++ components" --> "tooltip support"

3. Select "insert"

4. Add a button to the resource in the dialog box. The ID is idc_tooltip.

5. Find the following comment line in cdialog: oninitdialog:

 

// Todo: Use one of the following forms to add controls:

// M_tooltip.addtool (getdlgitem (IDC _),);

// M_tooltip.addtool (getdlgitem (IDC _),"");

Then add a line of code after the comment line:

M_tooltip.addtool (getdlgitem (idc_tooltip), "Show tooltip ");

 

 

After the above steps:

 

The following code is automatically added to the header file (*. h:

Public:

Virtual bool pretranslatemessage (MSG * PMSG );

 

The implementation file (*. cpp) is added with the method implementation:

Pretranslatemessage (MSG * PMSG );

 

Compile the program and run it. Move the mouse pointer to the tooltip button to display a tooltip.

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.