Share via


Manipulating the Tool Tip Control

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at Manipulating the Tool Tip Control.

Class CToolTipCtrl provides a group of member functions that control the various attributes of the CToolTipCtrl object and the tool tip window.

The initial, pop-up, and reshow durations for the tool tip windows can be set and retrieved with calls to GetDelayTime and SetDelayTime.

Change the appearance of the tool tip windows with the following functions:

  • GetMargin and SetMargin Retrieves and sets the width between the tool tip border and the tool tip text.

  • GetMaxTipWidth and SetMaxTipWidth Retrieves and sets the maximum width of the tool tip window.

  • GetTipBkColor and SetTipBkColor Retrieves and sets the background color of the tool tip window.

  • GetTipTextColor and SetTipTextColor Retrieves and sets the text color of the tool tip window.

In order for the tool tip control to be notified of important messages, such as WM_LBUTTONXXX messages, you must relay the messages to your tool tip control. The best method for this relay is to make a call to CToolTipCtrl::RelayEvent, in the PreTranslateMessage function of the owner window. The following example illustrates one possible method (assuming the tool tip control is called m_ToolTip):

BOOL CMyDialog::PreTranslateMessage(MSG* pMsg)
{
   if(pMsg->message== WM_LBUTTONDOWN ||
      pMsg->message== WM_LBUTTONUP ||
      pMsg->message== WM_MOUSEMOVE)
   {
      m_ToolTipCtrl.RelayEvent(pMsg);
   }

   return CDialog::PreTranslateMessage(pMsg);
}

To immediately remove a tool tip window, call the Pop member function.

See Also

Using CToolTipCtrl
Controls