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(); m_ToolTip->Create(this); //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 m_ToolTip->Activate(TRUE); //*** you could change the defualt settings *** //m_ToolTip->SetTipBkColor(RGB(0,255,0)); //m_ToolTip->SetTipTextColor(RGB(255,0,0)) return TRUE; }
Please refer the CToolTipCtrl class specific styles TTS_ALWAYSTIP and TTS_NOPREFIX in the MSDN.
Advertisements
Leave a Reply