Yes, it works, in fact I do it the exact same way, also in graphic graphics, however there are a few drawbacks / comments. Message processing is a bit unstable: some messages are not sent according to the documentation, and some workarounds are needed to provide autonomous control (without requiring parental assistance to reflect notifications).
What you do is declare a variable in your derived CWnd class
CToolTipCtrl m_ToolTipCtrl;
CString m_ToolTipContent;
Then do it in OnCreate:
m_ToolTipCtrl.Create(this, TTS_ALWAYSTIP);
m_ToolTipCtrl.Activate(TRUE);
Additionally, you can also set the delay time:
m_ToolTipCtrl.SetDelayTime(TTDT_AUTOPOP, -1);
m_ToolTipCtrl.SetDelayTime(TTDT_INITIAL, 0);
m_ToolTipCtrl.SetDelayTime(TTDT_RESHOW, 0);
If you want to show your tooltip (presumably in OnMouseMove ()), use
m_ToolTipCtrl.Pop();
UNICODE. , MBCS ( ), .
, ( OnMouseMove):
TOOLINFO ti = {0};
ti.cbSize = sizeof(TOOLINFO);
ti.uFlags = TTF_IDISHWND;
ti.uId = (UINT_PTR)m_hWnd;
ti.hwnd = m_hWnd;
ti.hinst = ::AfxGetInstanceHandle();
ti.lpszText = LPSTR_TEXTCALLBACK;
ti.rect = <rectangle where, when the mouse is over it, the tooltip should be shown>;
m_ToolTipCtrl.SendMessage(TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
m_ToolTipCtrl.Activate(TRUE);
m_ToolTipContent = "my tooltip content";
, TTNNeedText:
ON_NOTIFY_EX(TTN_NEEDTEXTA, 0, OnTTNNeedText)
ON_NOTIFY_EX(TTN_NEEDTEXTW, 0, OnTTNNeedText)
BOOL GraphCtrlOnTTNNeedText(UINT id, NMHDR* pTTTStruct, LRESULT* pResult)
{
TOOLTIPTEXT* pTTT = (TOOLTIPTEXT*)pTTTStruct;
strncpy_s(pTTT->lpszText, 80, m_ToolTipContent, _TRUNCATE);
return TRUE;
}
, , , .