]> git.saurik.com Git - wxWidgets.git/commitdiff
don't trust CDIS_FOCUS flag vale in custom drawing code, it is no more correct than...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 5 Mar 2006 11:26:13 +0000 (11:26 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 5 Mar 2006 11:26:13 +0000 (11:26 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37813 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/listctrl.cpp

index 14aa00809e656ade36d7d035715289e6ec754b0f..410219a869aaeac4ed8c7aadd1e61628cb4968bf 100644 (file)
@@ -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;