]> git.saurik.com Git - wxWidgets.git/commitdiff
another custom draw fix: leave space for the image even if the current item doesn...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 5 Mar 2006 12:12:11 +0000 (12:12 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 5 Mar 2006 12:12:11 +0000 (12:12 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37814 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/listctrl.cpp

index 410219a869aaeac4ed8c7aadd1e61628cb4968bf..2406e000c19c882ecc77a9627c8b068843a6002c 100644 (file)
@@ -2409,14 +2409,19 @@ static void HandleSubItemPrepaint(LPNMLVCUSTOMDRAW pLVCD, HFONT hfont)
     it.cchTextMax = WXSIZEOF(text);
     ListView_GetItem(hwndList, &it);
 
-    if ( it.iImage != -1 )
+    HIMAGELIST himl = ListView_GetImageList(hwndList, LVSIL_SMALL);
+    if ( himl && ImageList_GetImageCount(himl) )
     {
-        HIMAGELIST himl = ListView_GetImageList(hwndList, LVSIL_SMALL);
-
-        ImageList_Draw(himl, it.iImage, hdc, rc.left, rc.top,
-                       nmcd.uItemState & CDIS_SELECTED ? ILD_SELECTED
-                                                       : ILD_TRANSPARENT);
+        if ( it.iImage != -1 )
+        {
+            ImageList_Draw(himl, it.iImage, hdc, rc.left, rc.top,
+                           nmcd.uItemState & CDIS_SELECTED ? ILD_SELECTED
+                                                           : ILD_TRANSPARENT);
+        }
 
+        // notice that even if this item doesn't have any image, the list
+        // control still leaves space for the image if the image list is not
+        // empty (presumably so that items with and without images align?)
         int wImage, hImage;
         ImageList_GetIconSize(himl, &wImage, &hImage);