viksoe.dk

ListView Tip

ListView Tip


This article was submitted .


This is a control gone wrong. It turned out to be so annoying for the users that I had to remove it again. Anyway, it was a brave attempt to create a tracking ToolTip for a ListView control.

The idea behind it was simple: Since it's usually impossible to see the entire list row because of a large number of columns in a ListView, why not display a ToolTip with the column contents for each item. The ToolTip would have to be tracking, so when the user moved from item to item, the ToolTip displayed the contents of each item.
But, nah... it doesn't look cool and its utterly annoying.
Use it as a tracking ToolTip sample for WTL instead.

To use it, add a member variable to your dialog implementation file...

CListViewTrackTip m_ctrlTip
After initializing the ListView control, attach the tip:
  LRESULT OnInitDialog(UINT /*uMsg*/, 
                       WPARAM /*wParam*/, 
                       LPARAM /*lParam*/, 
                       BOOL& /*bHandled*/)
  {
    ...
    m_ctrlTip.Attach(m_hWnd, m_ctrlList);
    ...
  }
Then add the following macro to your message map:
  BEGIN_MSG_MAP(CMainDlg)
    ...
    CHAIN_MSG_MAP_MEMBER( m_ctrlTip )
  END_MSG_MAP()

Source Code Dependencies

Microsoft Visual C++ 6.0
Microsoft WTL 3.1 Library

Download Files

DownloadSource Code (3 Kb)