Adding Tooltip to any control in your Dialog (multiline)


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

This class helps the user in adding tooltip to any control in the dialog. Tooltip information can be more than one line.
  1. Add MFECToolTip.h and MFECToolTip.cpp in your project
  2. In OnInitDialog, call the Create function and add the tooltip information to any control you would like to have.

    For example:
    In SampleDlg.h add a variable

               MFECToolTip m_toolTip;

    In SampleDlg.cpp
                m_toolTip.Create( this );    // after creating, add the information
                m_toolTip.AddControlInfo( contol_ID, information, background_color, text_color );
                // control ID is of type UINT
                // information is of type CStringArray.
                // background_color and text_color are optional
  3. Override the dialog's PreTranslateMessage to handle mouse movement.
    BOOL CToolTipExDlg::PreTranslateMessage( MSG *pMsg )
            if( pMsg->message == WM_MOUSEMOVE )
                    POINT pt = pMsg->pt;    
                    ScreenToClient( &pt );
                    // this is the only function to call
                    m_toolTip.ShowToolTip( (CPoint)pt );
            return CDialog::PreTranslateMessage(pMsg);
  4. explicitly show the tooltip in a particular control, call ShowToolTip( controlID ) with control ID as parameter. Make sure you call AddControlInfo() to add information for this control, otherwise no tooltip is displayed.
  5. Delete or remove the existing tooltip information, call RemoveControlInfo( controlID ) and pass the control ID. If not found nothing happens.
  6. So, you can add and remove tooltip at runtime. Try!

Download demo project - 58 KB

Download source - 3.4 KB


  • How we can Add MFECToolTip.h and MFECToolTip.cpp in our project ?

    Posted by Legacy on 01/02/2003 08:00am

    Originally posted by: ashkan

    How we can Add MFECToolTip.h and MFECToolTip.cpp in our project ?
    I have inserted this files to my project but I cant have
    an object from CMFECToolTip because visualc++6 make an error from command #include "MFECToolTip.h" in MyProjectView
    I guess my method of adding a file to project is incorrect
    please guide me how can i add MFECToolTip.h and MFECToolTip.cpp files in my project ?
    thanks in advance,

  • Use the MFC Tooltip Control, it works much simpler.

    Posted by Legacy on 09/18/2002 07:00am

    Originally posted by: Conrad Braam

    Use the MFC Tooltip Control, it works much simpler.

  • it swallows resources

    Posted by Legacy on 08/05/2002 07:00am

    Originally posted by: Michael Aumer


    I use your tooltip and found out, that it swallows resources when being painted. You can check this out, by using the Resource Monitor (Win95/98Me only).

    Until today, I haven't found out why this happens. Can anybody give me some hints ?

    Thanks in advance...


  • Well

    Posted by Legacy on 10/19/2001 07:00am

    Originally posted by: Victor

    The thank all works perfectly

  • How about propertypages

    Posted by Legacy on 07/27/2000 07:00am

    Originally posted by: RccH

    How to use this in propertypages?

  • Do not working tooltip?

    Posted by Legacy on 02/07/2000 08:00am

    Originally posted by: D. Utenkov

    Check tab order of your controls.

    Be sure that your tipped controls has lower tab number.
    In detail : see ChildWindowFromPoint() method description.

    Good luck!

  • Tooltip will overwrite my frame

    Posted by Legacy on 01/05/2000 08:00am

    Originally posted by: Eric Lee

    I use this tooltip on check box.
    When the check box is click, I draw a blue frame on check
    box to indicate the status was changed.

    If I move mouse to check box and the tooltip will popup.
    Tooltip will overwrite my blue frame, how can I do to solve
    this problem?

    Thanks a lot!

    Eric Lee

  • Not working on CBitmap controls ...

    Posted by Legacy on 11/02/1999 08:00am

    Originally posted by: Amir Meshy

    I created a CBitmap control and assigned a tooltip on it.
    Unfortunatly this does not work.
    Any thought why ?

  • Adding Tooltip to any control in your Dialog

    Posted by Legacy on 05/04/1999 07:00am

    Originally posted by: Anonymous

    How can I add the run time information to the ToolTip.

  • Use standard tips! They can be multiline!

    Posted by Legacy on 04/02/1999 08:00am

    Originally posted by: Lukianov

    Hi boys!

    I had that problem to make my tips multiline. So I found hints how to do that.
    I found out an example here:
    // Author: Ferdinand V. Abne
    July 16, 1998 - Creation MFECToolTip

    Having tried this offer I wasn't satisfied. Than I asked my wife
    (she is a very programmer). She said:
    First you have to add into your project the ToolTip Support from the Components Gallery.
    (I have done that). Then if you use VC6, you have to insert in your dialog SetMaxTipWidth
    function after ones created by wizard:
    m_tooltip.Create(this); // Made by Wizard
    m_tooltip.Activate(TRUE); // Made by Wizard

    m_tooltip.SetMaxTipWidth(400); // You have to add it!
    m_tooltip.AddTool(GetDlgItem(IDOK),"This\n is Ok");
    If you use VC5 and earlier one you have to send a message to your tooltip instead
    calling non-existent function :-)
    m_tooltip.Create(this); // Made by Wizard
    m_tooltip.Activate(TRUE); // Made by Wizard

    // You have to add it!
    m_tooltip.SendMessage(TTM_SETMAXTIPWIDTH,0,400 );
    m_tooltip.AddTool(GetDlgItem(IDOK),"This\n is Ok");
    Our moderator Chris Maunder has added that that solution
    "depends on having IE4 installed or the latest commctrl32.dll."
    MSDN says
    Version 4.70 and later of comctl32.dll

    Windows NT: Requires version 5.0 or later (or version 4.0 with Internet Explorer 3.0 and later)..
    Windows: Requires Windows 98 (or Windows 95 with Internet Explorer 3.0 or later).
    Windows CE: Unsupported.
    Header: Declared in commctrl.h.

    Have a good time, colleagues.

  • Loading, Please Wait ...

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date