]> git.saurik.com Git - wxWidgets.git/commitdiff
post WM_CLOSE instead of deleting the inplace edit control (second incarnation of...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 29 Oct 2006 20:24:11 +0000 (20:24 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 29 Oct 2006 20:24:11 +0000 (20:24 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42657 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/listctrl.cpp

index a0301aec4a424747b6d8777a9c5a524c1e5ad150..f90acc043919d6183c90bb19a9b00c8107c9290f 100644 (file)
@@ -1394,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());
-    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