How to set a Tool Tip for a window

9 02 2009




Consider a situation that you have a dialog based application that contains several buttons and you want to appear tool tips when the user puts the cursor on the buttons and disappear when the cursor leave.





MFC provides a CToolTipCtrl  class for the Windows common tool tip control. Actually this is a CWnd derived class. Also we can customize the tool tip text and background by the functions SetTipBkColor, SetTipTextColor etc.




CToolTipCtrl* m_ToolTip;
BOOL CMyDialog::OnInitDialog()
   //create a tool tip control
   m_ToolTip= new CToolTipCtrl();
   //Get the button
   CWnd* pWnd = GetDlgItem(IDC_MY_TOOL_TIP_BUTTON);
   //add tool tip for our particular button
   m_ToolTip->AddTool(pWnd,"Click here for registering...");
   //activate the tool tip
   //*** you could change the defualt settings ***

   return TRUE;




Please refer the CToolTipCtrl class specific styles  TTS_ALWAYSTIP and  TTS_NOPREFIX in  the MSDN.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: