宣告在 *.h
CToolTipCtrl m_ctrlTT;
定義內容: *.cpp
BOOL SerialDlg::OnInitDialog()
{
......
//prompt
EnableToolTips(TRUE);//enable use it
m_ctrlTT.Create(this);
m_ctrlTT.Activate(TRUE);
m_ctrlTT.SetDelayTime(150);//delayTime
//IDC_BUTTON_SEND2 為要添加的控建IDC ,"Hello"為想添加的提示
m_ctrlTT.AddTool(GetDlgItem(IDC_BUTTON_SEND2), (LPCTSTR)"Hello");
return TRUE;
}
添加虛擬函示(ClassWizard中選擇虛擬函式 PreTranslateMessage)
BOOL SerialDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: 在此加入特定的程式碼和 (或) 呼叫基底類別
m_ctrlTT.RelayEvent(pMsg);
return CDialog::PreTranslateMessage(pMsg);
}
測試環境 MFC VC2015