From d778da2fbe5ee62c2a2159c3c1a2ca7fd122a412 Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Tue, 25 Jul 2000 12:26:59 +0000 Subject: [PATCH] Prevent the attempt to draw invalid image indexes. Provide the two pixel buffer between the image and the label. --- dlls/comctl32/listview.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index f0ab2d80e5b..03f85720b84 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -2157,6 +2157,8 @@ static VOID LISTVIEW_DrawItem(HWND hwnd, HDC hdc, INT nItem, RECT rcItem) INT nMixMode; DWORD dwBkColor; DWORD dwTextColor; + /* buffer of two pixels between the icon and the label */ + const INT ImageBuffer = 2; TRACE("(hwnd=%x, hdc=%x, nItem=%d)\n", hwnd, hdc, nItem); @@ -2174,32 +2176,33 @@ static VOID LISTVIEW_DrawItem(HWND hwnd, HDC hdc, INT nItem, RECT rcItem) if (infoPtr->himlState != NULL) { UINT uStateImage = (lvItem.state & LVIS_STATEIMAGEMASK) >> 12; - if (uStateImage != 0) + if (uStateImage > 0) { ImageList_Draw(infoPtr->himlState, uStateImage - 1, hdc, rcItem.left, rcItem.top, ILD_NORMAL); } - rcItem.left += infoPtr->iconSize.cx; + rcItem.left += ImageBuffer + infoPtr->iconSize.cx; } /* small icons */ if (infoPtr->himlSmall != NULL) { - if ((lvItem.state & LVIS_SELECTED) && (infoPtr->bFocus != FALSE)) + if ((lvItem.state & LVIS_SELECTED) && (infoPtr->bFocus != FALSE) && + (lvItem.iImage>=0)) { ImageList_SetBkColor(infoPtr->himlSmall, CLR_NONE); ImageList_Draw(infoPtr->himlSmall, lvItem.iImage, hdc, rcItem.left, rcItem.top, ILD_SELECTED); } - else + else if (lvItem.iImage>=0) { ImageList_SetBkColor(infoPtr->himlSmall, CLR_NONE); ImageList_Draw(infoPtr->himlSmall, lvItem.iImage, hdc, rcItem.left, rcItem.top, ILD_NORMAL); } - rcItem.left += infoPtr->iconSize.cx; + rcItem.left += ImageBuffer + infoPtr->iconSize.cx; } /* Don't bother painting item being edited */ @@ -2312,12 +2315,12 @@ bottom=%d)\n", hwnd, hdc, nItem, rcItem.left, rcItem.top, rcItem.right, { rcItem.top += ICON_TOP_PADDING; nDrawPosX += (infoPtr->iconSpacing.cx - infoPtr->iconSize.cx) / 2; - if (lvItem.state & LVIS_SELECTED) + if ((lvItem.state & LVIS_SELECTED) && (lvItem.iImage>=0)) { ImageList_Draw(infoPtr->himlNormal, lvItem.iImage, hdc, nDrawPosX, rcItem.top, ILD_SELECTED); } - else + else if (lvItem.iImage>=0) { ImageList_Draw(infoPtr->himlNormal, lvItem.iImage, hdc, nDrawPosX, rcItem.top, ILD_NORMAL);