Coding Tips (JavaScript/CSS/VBA/Win32)

Useful code snippets, tips and some Windows applications

How To Add Tooltips to an MFC dialog window

Step by step instructions

1. Declare a CToolTipCtrl variable in the dialog header file:

CToolTipCtrl m_tt;

2. In the OnInitDialog function create a tooltip window:

m_tt.Create(this);

3. Add a control to display a tool tip and text to the same function:

m_tt.AddTool(GetDlgItem (IDC_BUTTON_WHATEVER), "Tooltip text whatever");

4. Add the following code to the PreTranslateMessage function:

if(pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MOUSELAST)
m_tt.RelayEvent(pMsg);