From 95eea38eb0d68c1de65a51ae20c61ec29507258f Mon Sep 17 00:00:00 2001 From: followait Date: Thu, 12 Mar 2020 23:54:29 +0100 Subject: [PATCH] Fix bug when resetting wxListCtrl column header image in wxMSW Set LVCFMT_IMAGE, meaning that the column just uses an image from the image list, instead of LVCFMT_COL_HAS_IMAGES, meaning that the column contains the image from the image list and do not set LVCF_IMAGE when resetting the image, as this still reserved space for the (invalid) image, resulting in an extra blank area in the column header. Closes https://github.com/wxWidgets/wxWidgets/pull/1739 Closes #18617. --- src/msw/listctrl.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 89456899bb..dc9297fefe 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -3668,8 +3668,6 @@ static void wxConvertToMSWListCol(HWND hwndList, if ( item.m_mask & wxLIST_MASK_IMAGE ) { - 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) ) @@ -3689,14 +3687,18 @@ 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) - const int fmtImage = LVCFMT_BITMAP_ON_RIGHT | LVCFMT_COL_HAS_IMAGES; - + const int fmtImage = LVCFMT_BITMAP_ON_RIGHT | LVCFMT_IMAGE; if ( item.m_image != -1 ) + { lvCol.fmt |= fmtImage; - else // remove any existing image - lvCol.fmt &= ~fmtImage; - lvCol.iImage = item.m_image; + lvCol.mask |= LVCF_IMAGE; + lvCol.iImage = item.m_image; + } + else // remove any existing image + { + lvCol.fmt &= ~fmtImage; + } } }