ToolTips for Modal Dialog controls

Implementing tooltips for a modal dialog's controls is pretty easy. Just add the following code to your dialog's OnInitDialog function and implement PreTranslateMessage.

Changes to header files


private:
 HICON m_hIcon;
 CToolTipCtrl m_tool;

Add to implementation file

	
void CToolTipDlg::OnInitDialog()
{
 // Create tooltip object
 m_tool.Create(this); 

 // Add tooltip to the control
 m_tool.AddTool(GetDlgItem(Dialog control ID here),tooltip as string); 

 // TRUE to show tooltips,FALSE to disable tooltips
 m_tool.Activate(TRUE); 
}
Using ClassWizard, implement the PreTranslateMessage member function and modify it as follows.
	
void CToolTipDlg::PreTranslateMessage(MSG* pMsg)
{
 m_tool.RelayEvent(pMsg);
}

That's it! You now have tooltips on the controls!

Date Last Updated: February 1, 1999



Comments

  • How to create dynamic ToolTip

    Posted by Legacy on 04/22/2003 12:00am

    Originally posted by: Haresh Borse

    This is really cool.
    I want to create a dynamic tool tip i.e. there should be provision to change the text of tooltip at run time. I will very much thankful if anybody lets me know how to do this.

    Reply
  • very good

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

    Originally posted by: Geo George

    it works beautifully
    thanx

    Reply
  • how u make BOOL PreTanslateMessage() to void PreTranslateMessage()?

    Posted by Legacy on 02/25/2000 12:00am

    Originally posted by: Ramaprasad

    i tried to change the return type from BOOL to void, but it saying 'u cant overload the function by changing the return type'. can u pls tell me the way to add tooltips for controls in the dialog box?
    

    Reply
  • Re:How to get tooltips on modless dialogs

    Posted by Legacy on 08/13/1999 12:00am

    Originally posted by: Justin Hallet

    Define a class based on CDialog, then override OnInitDialog and Create ( UINT, CWnd* ) inside both of these test if the tooltip control has been created, if not create it.
    
    


    Reply
  • tool tip under modeless dialog box

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

    Originally posted by: Ling Tu

    By any chance, is it possible to enable tool tips to
    controls (eg. button, image, listbox) under modeless
    dialog box?

    -Ling Tu

    Reply
  • How to make it working with a composite control like ComboBox

    Posted by Legacy on 04/01/1999 12:00am

    Originally posted by: Philippe Minault

    If I use this code, it work very well except when the control is made with different other controls like a ComboBox (Edit + Listbox)or a custom control. Somebody has a solution to this problem ?

    Reply
  • Why this simply code doesn't works in a CFormView

    Posted by Legacy on 03/25/1999 12:00am

    Originally posted by: Fran�ois DROUHIN

    This code works very well in a dialog box (CDialog class), but it doesn't works in a form view (CFormView class).

    How can I make it works ?

    Fran�ois.

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

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

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