在OnInitDialog中
{
_tcscpy_s(m_ToolTip_str, 128, _T("连接柜台"));
m_ToolTip.Create(this, /* TTS_NOPREFIX| */ TTS_ALWAYSTIP /*| TTS_BALLOON*/);
m_ToolTip.AddTool(this, m_ToolTip_str);
m_ToolTip.GetToolInfo(m_ToolInfo, this);
m_ToolInfo.uFlags |= TTF_ABSOLUTE | TTF_TRACK;
m_ToolTip.SetToolInfo(&m_ToolInfo);
_tcscpy_s(m_ToolTip_title, 128, _T("柜台信息"));
m_ToolTip.SetTitle(TTI_INFO, m_ToolTip_title);
}
弹出气泡悬浮提示:
RECT rc;
//从窗口右上角弹出,
GetClientRect(&rc);
CPoint tmp{ rc.right - 150, rc.top }; //整体往里面挪一点。
ClientToScreen(&tmp);
if (lpstrTitle)
{
_stprintf_s(m_ToolTip_title, 128, _T("%s"), lpstrTitle);
m_ToolTip.SetTitle(uIcon, m_ToolTip_title);
}
_stprintf_s(m_ToolTip_str, 128, _T("%s"), _tooltip_str);
m_ToolTip.UpdateTipText(m_ToolTip_str, this);
m_ToolTip.SendMessage(TTM_TRACKPOSITION, 0, (LPARAM)MAKELONG(tmp.x, tmp.y));
m_ToolTip.SendMessage(TTM_TRACKACTIVATE, TRUE, (LPARAM) &(m_ToolInfo));
折腾要注意的地方:
m_ToolTip.Create(this, /* TTS_NOPREFIX| */ TTS_ALWAYSTIP /*| TTS_BALLOON*/);
m_ToolInfo.uFlags |= TTF_ABSOLUTE | TTF_TRACK;