Tooltips for CListCtrl
Posted on 1998-06-09
I want to support tooltips for CListCtrl window like it is done for CTreeCtrl.
The parent window of CListCtrl is derived from CToolBar, which was created with style CBRS_TOOLTIPS.
My CListCtrl contains only labels, which I want to extend by tooltip if they are cut by the border of parent window.
My attempt to do this is based on overiding OnToolHitTest () method. Until now I got no success.
Please check code below or suggest other way of supporting tooltips for CListCtrl.
Parent C3DErrorWnd is derived from CRollUpFrame, which is derived from SECControlBar (from Stingray Objective Toolkit library), which is derived from CToolBar.
m_List is CListCtrl, which is child of C3DErrorWnd.
Note: SendMessage (TB_GETTOOLTIPS, 0, 0) for C3DErrorWnd returns NULL.
EnableToolTips (TRUE) for C3DErrorWnd does not change anything and probably should not.
int C3DErrorWnd::OnToolHitTest( CPoint point, TOOLINFO* pTI ) const
// check child windows first by calling CRollUpFrame
int nHit = CRollUpFrame::OnToolHitTest(point, pTI);
if (nHit != -1)
// UINT nHitFlags = 0;
CPoint pt = point;
// Searching for CListCtrl item that corresponds to point
// nHit = m_List.HitTest(pt, &nHitFlags); // Does not work properly for some reason, was replaced by the following block
int nItem = 0;
while ((nItem = m_List.GetNextItem (-1, LVNI_ALL)) != -1)
m_List.GetItemRect( nItem, &ItemRect, LVIR_LABEL);
if (ItemRect.PtInRect (pt))
nHit = nItem;
// Setting TOOPINFO structure
if (nHit != -1)
CString str = m_List.GetItemText (nHit,0);
m_List.GetItemRect( nHit, &Rect, LVIR_LABEL );