views:

182

answers:

2

The ListView control of Windows Explorer gives a highlight to whatever item is under the mouse, without affecting the current selection. This helps enormously with relating what item a given tooltip applies to within a listview - especially in report mode.

However, I am currently unable to find any APIs that would give my MFC application's CListCtrl that same behavior. Extended styles only have LVS_EX_TRACKSELECT, which actually alters the current selection (yuck!).

Does anyone know how to provide a standard CListCtrl (or whatever that actually sits on top of) the mouse-hot-tracking capability?

I found some articles on how to provide per cell and per row tooltip text, but its hard to tell what the tooltips relate to without something highlighting...

+1  A: 

Include an extended style of LVS_EX_TWOCLICKACTIVATE or LVS_EX_ONECLICKACTIVATE. This is referred to as "hot tracking" (as opposed to hot track selection). http://msdn.microsoft.com/en-us/library/bb774732%28VS.85%29.aspx

Kyle Alons
This second answer sounded like it was going to work. However, I don't get any hot-tracking (using ONECLICKACTIVATE) to work. I've tried that style alone, and with LVS_EX_TRACKSELECT. But even with a 6.0 controls manifest, under Win7, I get the older look, and no hot-tracking :(
Mordachai
This sample displays hot tracking on Win7 (and it doesn't even appear that specifying an extended style is needed): http://www.codeproject.com/KB/list/CListCtrl_column_picker.aspx
Kyle Alons
A: 

You can set the explorer theme to your list control. That way it will get a nicer look and you will also get the highlighting you want:

SetWindowTheme(hListControl, L"Explorer", NULL);
Stefan