#pragma hdrstop
#endif
+#if wxUSE_LISTCTRL
+
#ifdef __WIN95__
#ifndef WX_PRECOMP
#include "wx/msw/private.h"
-#ifdef __GNUWIN32_OLD__
+#if ((defined(__GNUWIN32_OLD__) || defined(__TWIN32__)) && !defined(__CYGWIN10__))
#include "wx/msw/gnuwin32/extra.h"
#else
#include <commctrl.h>
DWORD wstyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP |
LVS_SHAREIMAGELISTS | LVS_SHOWSELALWAYS;
+
+ if ( m_windowStyle & wxCLIP_SIBLINGS )
+ wstyle |= WS_CLIPSIBLINGS;
+
if ( wxStyleHasBorder(m_windowStyle) )
wstyle |= WS_BORDER;
m_baseStyle = wstyle;
LV_ITEM item;
wxConvertToMSWListItem(this, info, item);
- // check whether it has any custom attributes
- if ( info.HasAttributes() )
+ item.cchTextMax = 0;
+ if ( !ListView_SetItem(GetHwnd(), &item) )
{
+ wxLogDebug(_T("ListView_SetItem() failed"));
- wxListItemAttr *attr;
- attr = (wxListItemAttr*) m_attrs.Get(item.iItem);
+ return FALSE;
+ }
- if (attr == NULL)
+ // we need to update the item immediately to show the new image
+ bool updateNow = (info.m_mask & wxLIST_MASK_IMAGE) != 0;
- m_attrs.Put(item.iItem, (wxObject *)new wxListItemAttr(*info.GetAttributes()));
+ // check whether it has any custom attributes
+ if ( info.HasAttributes() )
+ {
+ wxListItemAttr *attr = (wxListItemAttr *)m_attrs.Get(item.iItem);
- else *attr = *info.GetAttributes();
+ if ( attr == NULL )
+ m_attrs.Put(item.iItem, (wxObject *)new wxListItemAttr(*info.GetAttributes()));
+ else
+ *attr = *info.GetAttributes();
m_hasAnyAttr = TRUE;
+
+ // if the colour has changed, we must redraw the item
+ updateNow = TRUE;
}
- item.cchTextMax = 0;
- bool ok = ListView_SetItem(GetHwnd(), &item) != 0;
- if ( ok && (info.m_mask & wxLIST_MASK_IMAGE) )
+ if ( updateNow )
{
- // make the change visible
+ // we need this to make the change visible right now
ListView_Update(GetHwnd(), item.iItem);
}
- return ok;
+ return TRUE;
}
long wxListCtrl::SetItem(long index, int col, const wxString& label, int imageId)
{
wxASSERT( (textControlClass->IsKindOf(CLASSINFO(wxTextCtrl))) );
+ // VS: ListView_EditLabel requires that the list has focus.
+ SetFocus();
HWND hWnd = (HWND) ListView_EditLabel(GetHwnd(), item);
if (m_textCtrl)
}
else
{
- lvItem.pszText = WXSTRINGCAST info.m_text;
+ lvItem.pszText = info.m_text;
if ( lvItem.pszText )
lvItem.cchTextMax = info.m_text.Length();
else
#endif // __WIN95__
+#endif // wxUSE_LISTCTRL