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