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

HICON m_hIcon;
CToolTipCtrl m_tool;

Add to implementation file

void CToolTipDlg::OnInitDialog()
// Create tooltip object

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

// TRUE to show tooltips,FALSE to disable tooltips

Using ClassWizard, implement the PreTranslateMessage member function and modify it as follows.

void CToolTipDlg::PreTranslateMessage(MSG* pMsg)

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

Date Last Updated: February 1, 1999

More by Author

Must Read