From: Vadim Zeitlin Date: Sun, 5 Mar 2006 11:26:13 +0000 (+0000) Subject: don't trust CDIS_FOCUS flag vale in custom drawing code, it is no more correct than... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/13845bd57c75764de50f420949a6ea9999d6d9e0?ds=inline 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 --- diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 14aa00809e..410219a869 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -2449,7 +2449,8 @@ static void HandleItemPaint(LPNMLVCUSTOMDRAW pLVCD, HFONT hfont) { 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 // 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; } - if ( (DWORD)i == nmcd.dwItemSpec ) + if ( i == item ) { nmcd.uItemState |= CDIS_SELECTED; 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 ) { int syscolFg, syscolBg;