From: Vadim Zeitlin Date: Sat, 14 Jul 2001 02:03:23 +0000 (+0000) Subject: implemented RefreshItem(s) under MSW X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a7f560a2cb7f512c8fe3a9f6ff501c551e9e8941 implemented RefreshItem(s) under MSW git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11032 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/msw/listctrl.h b/include/wx/msw/listctrl.h index b4b1597388..14140398c3 100644 --- a/include/wx/msw/listctrl.h +++ b/include/wx/msw/listctrl.h @@ -231,6 +231,10 @@ public: // returns true if it is a virtual list control bool IsVirtual() const { return (GetWindowStyle() & wxLC_VIRTUAL) != 0; } + // refresh items selectively (only useful for virtual list controls) + void RefreshItem(long item); + void RefreshItems(long itemFrom, long itemTo); + // Operations //////////////////////////////////////////////////////////////////////////// diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index ddc46eb6d3..107623555b 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -1683,6 +1683,14 @@ WXLPARAM wxListCtrl::OnCustomDraw(WXLPARAM lParam) case CDDS_ITEMPREPAINT: { size_t item = (size_t)nmcd.dwItemSpec; + if ( item >= (size_t)GetItemCount() ) + { + // we get this message with item == 0 for an empty control, + // we must ignore it as calling OnGetItemAttr() would be + // wrong + return CDRF_DODEFAULT; + } + wxListItemAttr *attr = IsVirtual() ? OnGetItemAttr(item) : (wxListItemAttr *)m_attrs.Get(item); @@ -1850,6 +1858,22 @@ void wxListCtrl::SetItemCount(long count) } } +void wxListCtrl::RefreshItem(long item) +{ + if ( !ListView_Update(GetHwnd(), item) ) + { + wxLogLastError(_T("ListView_Update")); + } +} + +void wxListCtrl::RefreshItems(long itemFrom, long itemTo) +{ + for ( long item = itemFrom; item <= itemTo; item++ ) + { + RefreshItem(item); + } +} + // ---------------------------------------------------------------------------- // wxListItem // ----------------------------------------------------------------------------