Did you know that: LVN_GETINFOTIP?

Did you know that when you handle LVN_GETINFOTIP notification message and you are provided with NMLVGETINFOTIP structure, you cannot just supply your own pszText string for the tooltip text? Instead you have to copy your string into supplied buffer, such as using _tcsncpy function. Otherwise things would not work.

BEGIN_MSG_MAP_EX(CFooPropertyPage)
	CHAIN_MSG_MAP(CPropertyPageT)
	...
	MSG_LVN_GETINFOTIP(IDC_FOOLISTVIEW, OnFooListViewGetInfoTip) 
	REFLECT_NOTIFICATIONS()
END_MSG_MAP()
...
LRESULT OnFooListViewGetInfoTip(NMLVGETINFOTIP* pHeader)
{
	ATLASSERT(!pHeader->lParam);
	CFoo* pFoo = m_FooListView.GetItemData(pHeader->iItem);
	CString& sTextBuffer = m_ModelListView.GetTextBufferString(TRUE);
	...
	sTextBuffer.TrimRight(_T("\t\n\r "));
	_tcsncpy(pHeader->pszText, sTextBuffer, pHeader->cchTextMax - 1);
	pHeader->pszText[pHeader->cchTextMax - 1] = 0;
	return 0;
}

Leave a Reply