From 43e7536c878fb89bb85e39275b0b2c295d55308e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 8 Oct 2019 02:08:21 +0200 Subject: [PATCH 1/2] Use correct mask for wxListCtrl column bitmaps in wxMSW Do use LVCFMT_COL_HAS_IMAGES as it's the right flag to use according to the documentation, unlike LVCFMT_IMAGE which seems to have worked only accidentally. See #18523. --- src/msw/listctrl.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index e9feef55b4..dd637311b5 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -3660,9 +3660,6 @@ static void wxConvertToMSWListCol(HWND hwndList, // seem to be generally nicer than on the left and the generic // version only draws them on the right (we don't have a flag to // specify the image location anyhow) - // - // we don't use LVCFMT_COL_HAS_IMAGES because it doesn't seem to - // make any difference in my tests -- but maybe we should? if ( item.m_image != -1 ) { // as we're going to overwrite the format field, get its @@ -3680,7 +3677,7 @@ static void wxConvertToMSWListCol(HWND hwndList, lvCol.mask |= LVCF_FMT; } - lvCol.fmt |= LVCFMT_BITMAP_ON_RIGHT | LVCFMT_IMAGE; + lvCol.fmt |= LVCFMT_BITMAP_ON_RIGHT | LVCFMT_COL_HAS_IMAGES; } lvCol.iImage = item.m_image; From 5d6f92d505e74d5bf60da809f0bc52ae7b988cb9 Mon Sep 17 00:00:00 2001 From: followait Date: Tue, 8 Oct 2019 02:09:56 +0200 Subject: [PATCH 2/2] Fix clearing images of wxMSW wxListCtrl columns Resetting LVCFMT_COL_HAS_IMAGES does work and removes the image shown in the column without leaving any space for it, unlike the previously used version. Closes #18523. --- src/msw/listctrl.cpp | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index dd637311b5..c3de6a8bfa 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -3656,29 +3656,31 @@ static void wxConvertToMSWListCol(HWND hwndList, { lvCol.mask |= LVCF_IMAGE; + // as we're going to overwrite the format field, get its + // current value first -- unless we want to overwrite it anyhow + if ( !(lvCol.mask & LVCF_FMT) ) + { + LV_COLUMN lvColOld; + wxZeroMemory(lvColOld); + lvColOld.mask = LVCF_FMT; + if ( ListView_GetColumn(hwndList, col, &lvColOld) ) + { + lvCol.fmt = lvColOld.fmt; + } + + lvCol.mask |= LVCF_FMT; + } + // we use LVCFMT_BITMAP_ON_RIGHT because the images on the right // seem to be generally nicer than on the left and the generic // version only draws them on the right (we don't have a flag to // specify the image location anyhow) + const int fmtImage = LVCFMT_BITMAP_ON_RIGHT | LVCFMT_COL_HAS_IMAGES; + if ( item.m_image != -1 ) - { - // as we're going to overwrite the format field, get its - // current value first -- unless we want to overwrite it anyhow - if ( !(lvCol.mask & LVCF_FMT) ) - { - LV_COLUMN lvColOld; - wxZeroMemory(lvColOld); - lvColOld.mask = LVCF_FMT; - if ( ListView_GetColumn(hwndList, col, &lvColOld) ) - { - lvCol.fmt = lvColOld.fmt; - } - - lvCol.mask |= LVCF_FMT; - } - - lvCol.fmt |= LVCFMT_BITMAP_ON_RIGHT | LVCFMT_COL_HAS_IMAGES; - } + lvCol.fmt |= fmtImage; + else // remove any existing image + lvCol.fmt &= ~fmtImage; lvCol.iImage = item.m_image; }