]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/listctrl.cpp
fixed incorrectly inversed test for parent [not] being deleted (patch 1624472)
[wxWidgets.git] / src / msw / listctrl.cpp
index d3adde8fd179e63c7794b4e11b07b84636c247ad..6f3a70e1366a2574ba3bd5d8c08680548d09cc26 100644 (file)
@@ -26,6 +26,8 @@
 
 #if wxUSE_LISTCTRL
 
 
 #if wxUSE_LISTCTRL
 
+#include "wx/listctrl.h"
+
 #ifndef WX_PRECOMP
     #include "wx/msw/wrapcctl.h" // include <commctrl.h> "properly"
     #include "wx/app.h"
 #ifndef WX_PRECOMP
     #include "wx/msw/wrapcctl.h" // include <commctrl.h> "properly"
     #include "wx/app.h"
@@ -37,7 +39,6 @@
 #endif
 
 #include "wx/imaglist.h"
 #endif
 
 #include "wx/imaglist.h"
-#include "wx/listctrl.h"
 
 #include "wx/msw/private.h"
 
 
 #include "wx/msw/private.h"
 
@@ -1393,21 +1394,19 @@ bool wxListCtrl::EndEditLabel(bool cancel)
 {
     // m_textCtrl is not always ready, ie. in EVT_LIST_BEGIN_LABEL_EDIT
     HWND hwnd = ListView_GetEditControl(GetHwnd());
 {
     // m_textCtrl is not always ready, ie. in EVT_LIST_BEGIN_LABEL_EDIT
     HWND hwnd = ListView_GetEditControl(GetHwnd());
-    bool b = (hwnd != NULL);
-    if (b)
-    {
-        if (cancel)
-            ::SetWindowText(hwnd, wxEmptyString); // dubious but better than nothing
-        if (m_textCtrl)
-        {
-            m_textCtrl->UnsubclassWin();
-            m_textCtrl->SetHWND(0);
-            delete m_textCtrl;
-            m_textCtrl = NULL;
-        }
-        ::DestroyWindow(hwnd);
-    }
-    return b;
+    if ( !hwnd )
+        return false;
+
+    if ( cancel )
+        ::SetWindowText(hwnd, wxEmptyString); // dubious but better than nothing
+
+    // we shouldn't destroy the control ourselves according to MSDN, which
+    // proposes WM_CANCELMODE to do this, but it doesn't seem to work
+    //
+    // posting WM_CLOSE to it does seem to work without any side effects
+    ::PostMessage(hwnd, WM_CLOSE, 0, 0);
+
+    return true;
 }
 
 // Ensures this item is visible
 }
 
 // Ensures this item is visible
@@ -1894,7 +1893,7 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
     }
     else
 #endif // defined(HDN_BEGINTRACKA)
     }
     else
 #endif // defined(HDN_BEGINTRACKA)
-        if ( nmhdr->hwndFrom == GetHwnd() )
+    if ( nmhdr->hwndFrom == GetHwnd() )
     {
         // almost all messages use NM_LISTVIEW
         NM_LISTVIEW *nmLV = (NM_LISTVIEW *)nmhdr;
     {
         // almost all messages use NM_LISTVIEW
         NM_LISTVIEW *nmLV = (NM_LISTVIEW *)nmhdr;
@@ -2317,10 +2316,13 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
                     }
 #endif // NM_CUSTOMDRAW
 
                     }
 #endif // NM_CUSTOMDRAW
 
-                    // a little dose of healthy paranoia: as we never use
-                    // LVM_SETCALLBACKMASK we're not supposed to get these ones
-                    wxASSERT_MSG( !(lvi.mask & LVIF_STATE),
-                                  _T("we don't support state callbacks yet!") );
+                    // even though we never use LVM_SETCALLBACKMASK, we still
+                    // can get messages with LVIF_STATE in lvi.mask under Vista
+                    if ( lvi.mask & LVIF_STATE )
+                    {
+                        // we don't have anything to return from here...
+                        lvi.stateMask = 0;
+                    }
 
                     return true;
                 }
 
                     return true;
                 }