Don't use first image for wxListCtrl items without any image

Native wxListCtrl in wxMSW behaved inconsistently with the generic one
and used the first image for the new items inserted into it even if no
image was explicitly specified.

Work around this unhelpful native behaviour by using I_IMAGENONE for the
items without images.

Closes #26062.
This commit is contained in:
Vadim Zeitlin
2026-01-02 17:41:30 +01:00
parent aaa151f5c7
commit 2ab82b5a20
+10
View File
@@ -2066,6 +2066,16 @@ long wxListCtrl::InsertItem(const wxListItem& info)
LV_ITEM item;
wxConvertToMSWListItem(this, info, item);
// When inserting items into a control with an image list, the first image
// is used by default, so we need to explicitly specify that we don't want
// any image if it wasn't set.
if ( !(item.mask & LVIF_IMAGE) )
{
item.iImage = I_IMAGENONE;
item.mask |= LVIF_IMAGE;
}
item.mask &= ~LVIF_PARAM;
// check whether we need to allocate our internal data