don't trust CDIS_FOCUS flag vale in custom drawing code, it is no more correct than CDIS_SELECTED so we have to get it from the control itself directly too

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37813 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2006-03-05 11:26:13 +00:00
parent 5ce8a6113a
commit 13845bd57c

View File

@ -2449,7 +2449,8 @@ static void HandleItemPaint(LPNMLVCUSTOMDRAW pLVCD, HFONT hfont)
{ {
NMCUSTOMDRAW& nmcd = pLVCD->nmcd; // just a shortcut NMCUSTOMDRAW& nmcd = pLVCD->nmcd; // just a shortcut
HWND hwndList = nmcd.hdr.hwndFrom; const HWND hwndList = nmcd.hdr.hwndFrom;
const int item = nmcd.dwItemSpec;
// unfortunately we can't trust CDIS_SELECTED, it is often set even when // unfortunately we can't trust CDIS_SELECTED, it is often set even when
// the item is not at all selected for some reason (comctl32 6), but we // the item is not at all selected for some reason (comctl32 6), but we
@ -2465,13 +2466,23 @@ static void HandleItemPaint(LPNMLVCUSTOMDRAW pLVCD, HFONT hfont)
break; break;
} }
if ( (DWORD)i == nmcd.dwItemSpec ) if ( i == item )
{ {
nmcd.uItemState |= CDIS_SELECTED; nmcd.uItemState |= CDIS_SELECTED;
break; break;
} }
} }
// same thing for CDIS_FOCUS (except simpler as there is only one of them)
if ( ListView_GetNextItem(hwndList, -1, LVNI_FOCUSED) == item )
{
nmcd.uItemState |= CDIS_FOCUS;
}
else
{
nmcd.uItemState &= ~CDIS_FOCUS;
}
if ( nmcd.uItemState & CDIS_SELECTED ) if ( nmcd.uItemState & CDIS_SELECTED )
{ {
int syscolFg, syscolBg; int syscolFg, syscolBg;