From e64658ed9958f4843df76553f2a791a35e867f17 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 8 Feb 2006 22:15:34 +0000 Subject: [PATCH] don't lose the alignment flags when setting the column image (replaces patch 1411870; closes bug 1155504) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37396 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/listctrl.cpp | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 6b9ef732a6..7a365c7a0e 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -78,7 +78,9 @@ static void wxConvertFromMSWListItem(HWND hwndListCtrl, /* const */ LV_ITEM& lvItem); // convert our wxListItem to LV_COLUMN -static void wxConvertToMSWListCol(int col, const wxListItem& item, +static void wxConvertToMSWListCol(HWND hwndList, + int col, + const wxListItem& item, LV_COLUMN& lvCol); // ---------------------------------------------------------------------------- @@ -666,7 +668,7 @@ bool wxListCtrl::GetColumn(int col, wxListItem& item) const bool wxListCtrl::SetColumn(int col, const wxListItem& item) { LV_COLUMN lvCol; - wxConvertToMSWListCol(col, item, lvCol); + wxConvertToMSWListCol(GetHwnd(), col, item, lvCol); return ListView_SetColumn(GetHwnd(), col, &lvCol) != 0; } @@ -1569,7 +1571,7 @@ long wxListCtrl::InsertItem(long index, const wxString& label, int imageIndex) long wxListCtrl::InsertColumn(long col, const wxListItem& item) { LV_COLUMN lvCol; - wxConvertToMSWListCol(col, item, lvCol); + wxConvertToMSWListCol(GetHwnd(), col, item, lvCol); if ( !(lvCol.mask & LVCF_WIDTH) ) { @@ -2796,7 +2798,9 @@ static void wxConvertToMSWListItem(const wxListCtrl *ctrl, lvItem.mask |= LVIF_IMAGE; } -static void wxConvertToMSWListCol(int WXUNUSED(col), const wxListItem& item, +static void wxConvertToMSWListCol(HWND hwndList, + int col, + const wxListItem& item, LV_COLUMN& lvCol) { wxZeroMemory(lvCol); @@ -2836,9 +2840,9 @@ static void wxConvertToMSWListCol(int WXUNUSED(col), const wxListItem& item, { if ( wxTheApp->GetComCtl32Version() >= 470 ) { - lvCol.mask |= LVCF_IMAGE | LVCF_FMT; + lvCol.mask |= LVCF_IMAGE; - // we use LVCFMT_BITMAP_ON_RIGHT because thei mages on the right + // 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) @@ -2846,7 +2850,24 @@ static void wxConvertToMSWListCol(int WXUNUSED(col), const wxListItem& item, // 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 + // 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_IMAGE; + } lvCol.iImage = item.m_image; } -- 2.45.2