]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/listctrl.cpp
Implement wxWindowDC::Clear()
[wxWidgets.git] / src / msw / listctrl.cpp
index 73d138f1e30eb2dc629009c47573e30a1004961e..b009824380f8afb63c6f7323367e31b31e35bf07 100644 (file)
@@ -45,7 +45,7 @@
 
 #include "wx/msw/private.h"
 
 
 #include "wx/msw/private.h"
 
-#if ((defined(__GNUWIN32_OLD__) || defined(__TWIN32__)) && !defined(__CYGWIN10__))
+#if defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__)
     #include "wx/msw/gnuwin32/extra.h"
 #else
     #include <commctrl.h>
     #include "wx/msw/gnuwin32/extra.h"
 #else
     #include <commctrl.h>
@@ -304,10 +304,11 @@ bool wxListCtrl::DoCreateControl(int x, int y, int w, int h)
     DWORD wstyle = m_baseStyle;
 
     WXDWORD exStyle = 0;
     DWORD wstyle = m_baseStyle;
 
     WXDWORD exStyle = 0;
-    (void) MSWGetStyle(GetWindowStyle(), & exStyle) ;
+    WXDWORD standardStyle = MSWGetStyle(GetWindowStyle(), & exStyle) ;
 
     long oldStyle = 0; // Dummy
     wstyle |= ConvertToMSWStyle(oldStyle, m_windowStyle);
 
     long oldStyle = 0; // Dummy
     wstyle |= ConvertToMSWStyle(oldStyle, m_windowStyle);
+    wstyle |= standardStyle;
 
     // Create the ListView control.
     m_hWnd = (WXHWND)CreateWindowEx(exStyle,
 
     // Create the ListView control.
     m_hWnd = (WXHWND)CreateWindowEx(exStyle,
@@ -1840,7 +1841,19 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
                     wxConvertFromMSWListItem(NULL, event.m_item, item);
                     if ( ((LV_ITEM)item).pszText == NULL ||
                          ((LV_ITEM)item).iItem == -1 )
                     wxConvertFromMSWListItem(NULL, event.m_item, item);
                     if ( ((LV_ITEM)item).pszText == NULL ||
                          ((LV_ITEM)item).iItem == -1 )
+                    {
+                        // don't keep a stale wxTextCtrl around
+                        if ( m_textCtrl )
+                        {
+                            // EDIT control will be deleted by the list control itself so
+                            // prevent us from deleting it as well
+                            m_textCtrl->UnsubclassWin();
+                            m_textCtrl->SetHWND(0);
+                            delete m_textCtrl;
+                            m_textCtrl = NULL;
+                        }
                         return FALSE;
                         return FALSE;
+                    }
 
                     event.m_itemIndex = event.m_item.m_itemId;
                 }
 
                     event.m_itemIndex = event.m_item.m_itemId;
                 }
@@ -1852,7 +1865,19 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
                     wxConvertFromMSWListItem(NULL, event.m_item, item);
                     if ( ((LV_ITEM)item).pszText == NULL ||
                          ((LV_ITEM)item).iItem == -1 )
                     wxConvertFromMSWListItem(NULL, event.m_item, item);
                     if ( ((LV_ITEM)item).pszText == NULL ||
                          ((LV_ITEM)item).iItem == -1 )
+                    {
+                        // don't keep a stale wxTextCtrl around
+                        if ( m_textCtrl )
+                        {
+                            // EDIT control will be deleted by the list control itself so
+                            // prevent us from deleting it as well
+                            m_textCtrl->UnsubclassWin();
+                            m_textCtrl->SetHWND(0);
+                            delete m_textCtrl;
+                            m_textCtrl = NULL;
+                        }
                         return FALSE;
                         return FALSE;
+                    }
 
                     event.m_itemIndex = event.m_item.m_itemId;
                 }
 
                     event.m_itemIndex = event.m_item.m_itemId;
                 }
@@ -2055,21 +2080,18 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
 
                     eventType = wxEVT_COMMAND_LIST_CACHE_HINT;
 
 
                     eventType = wxEVT_COMMAND_LIST_CACHE_HINT;
 
-                    // we get some really stupid cache hints like ones for items in
-                    // range 0..0 for an empty control or, after deleting an item,
-                    // for items in invalid range - filter this garbage out
-                    if ( cacheHint->iFrom < cacheHint->iTo )
-                    {
-                        event.m_oldItemIndex = cacheHint->iFrom;
-
-                        long iMax = GetItemCount();
-                        event.m_itemIndex = cacheHint->iTo < iMax ? cacheHint->iTo
-                                                                  : iMax - 1;
-                    }
-                    else
-                    {
+                    // we get some really stupid cache hints like ones for
+                    // items in range 0..0 for an empty control or, after
+                    // deleting an item, for items in invalid range -- filter
+                    // this garbage out
+                    if ( cacheHint->iFrom > cacheHint->iTo )
                         return FALSE;
                         return FALSE;
-                    }
+
+                    event.m_oldItemIndex = cacheHint->iFrom;
+
+                    const long iMax = GetItemCount();
+                    event.m_itemIndex = cacheHint->iTo < iMax ? cacheHint->iTo
+                                                              : iMax - 1;
                 }
                 break;
 
                 }
                 break;
 
@@ -2350,7 +2372,7 @@ void wxListCtrl::SetItemCount(long count)
 {
     wxASSERT_MSG( IsVirtual(), _T("this is for virtual controls only") );
 
 {
     wxASSERT_MSG( IsVirtual(), _T("this is for virtual controls only") );
 
-    if ( !::SendMessage(GetHwnd(), LVM_SETITEMCOUNT, (WPARAM)count, 0) )
+    if ( !::SendMessage(GetHwnd(), LVM_SETITEMCOUNT, (WPARAM)count, LVSICF_NOSCROLL) )
     {
         wxLogLastError(_T("ListView_SetItemCount"));
     }
     {
         wxLogLastError(_T("ListView_SetItemCount"));
     }