]> git.saurik.com Git - wxWidgets.git/commitdiff
implemented RefreshItem(s) under MSW
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 14 Jul 2001 02:03:23 +0000 (02:03 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 14 Jul 2001 02:03:23 +0000 (02:03 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11032 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/listctrl.h
src/msw/listctrl.cpp

index b4b1597388a9f8b7aa7e0ce38ce4f25b4cd6bb5f..14140398c3301ec9d7a32b3ecf01fe9bcc0f4709 100644 (file)
@@ -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
     ////////////////////////////////////////////////////////////////////////////
 
index ddc46eb6d354b257c819d655aff13a289a7d3272..107623555b3fec9692fdacf03d8cab8db682bead 100644 (file)
@@ -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
 // ----------------------------------------------------------------------------