Re: having trouble programmatically selecting CListCtrl item
"Tony C." <me@here.com> wrote in message
news:31n3h5hd3t137oiuqs8evhtc9tlq38j1ag@4ax.com...
Looks like I might have to investigate subclassing..
Perhaps not. The parent window of the CListCtrl could implement
NM_CUSTOMDRAW (OnCustomDraw). Windows makes it slightly difficult to paint
the background of the selected item. Here is what I commented in my code
when I attempted to do this:
void CPageNetworks::OnCustomDraw(NMHDR* pNMHDR, LRESULT *pResult)
{
LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)pNMHDR;
// Windows disregards our specified background color, if the item is
// currently selected. It insists on painting it in the standard
// COLOR_HIGHLIGHT color. If the item is selected and is the current
// connection, then we must paint it in the user-specified color (e.g.
yellow).
// We trick Windows by setting the LVIS_SELECTED state to false.
// Then Windows will not paint the background in COLOR_HIGHLIGHT color,
// retaining our color. We must reset the selected state immediately
// after the painting is done.
// This idea was found on Codeguru: "Personalizing highlight colors
through custom draw"
// http://www.codeguru.com/Cpp/controls/listview/article.php/c1035
...
}
-- David