1..h 定義
CToolTipCtrl m_ToolTip;
2. .cpp創建顯示
初始化函數中:
CRect rectTip;
GetDlgItem(IDC_XXX)->GetWindowRect(&rectTip);
ScreenToClient(&rectTip);
EnableToolTips(TRUE);
m_ToolTip.Create(this, TTS_ALWAYSTIP);
m_ToolTip.AddTool(this, g_szTipText, rectTip, 1); //用此方法不受控件的enable狀態限制
m_ToolTip.SetTipBkColor(COLORREF(RGB(255, 255, 255))); //background color
m_ToolTip.SetMaxTipWidth(300);
m_ToolTip.SetDelayTime(TTDT_INITIAL, 5); //鼠標指向多久後顯示提示,毫秒
m_ToolTip.SetDelayTime(TTDT_AUTOPOP, 30000); //鼠標保持指向,提示顯示多久,毫秒
m_ToolTip.Activate(TRUE); //顯示 如若不讓其顯示 設爲F
BOOL CDlgApiSimple::PreTranslateMessage( MSG* pMsg )
{
// TODO: Add your specialized code here and/or call the base class
if (NULL != m_ToolTip.GetSafeHwnd())
{
m_ToolTip.RelayEvent(pMsg);
}
return CDialog::PreTranslateMessage(pMsg);
}
//--------------------------------------------------------over------------------------------------------------------------------------