]> git.saurik.com Git - wxWidgets.git/commitdiff
Don't use ListView_CancelEditLabel() as it doesn't work as expected.
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 2 Dec 2011 00:50:29 +0000 (00:50 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 2 Dec 2011 00:50:29 +0000 (00:50 +0000)
ListView_CancelEditLabel() doesn't revert the controls value to the original
text as expected, so don't use it and revert to sending VK_ESCAPE to the
in-place edit control instead under all versions of Windows.

See #7663.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69894 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/listctrl.cpp

index 716fbcaab1b8fd1941205500cd0c18fa32491913..1f06aa3074686793dd222a6d70537e70d7a30527 100644 (file)
@@ -1490,21 +1490,15 @@ bool wxListCtrl::EndEditLabel(bool cancel)
     if ( !hwnd )
         return false;
 
-    // Newer versions of Windows have a special message for cancelling editing,
-    // use it if available.
-#ifdef ListView_CancelEditLabel
-    if ( cancel && (wxApp::GetComCtl32Version() >= 600) )
-    {
-        ListView_CancelEditLabel(GetHwnd());
-    }
-    else
-#endif // ListView_CancelEditLabel
-    {
-        // We shouldn't destroy the control ourselves according to MSDN, which
-        // proposes WM_CANCELMODE to do this, but it doesn't seem to work so
-        // emulate the corresponding user action instead.
-        ::SendMessage(hwnd, WM_KEYDOWN, cancel ? VK_ESCAPE : VK_RETURN, 0);
-    }
+    // Newer versions of Windows have a special ListView_CancelEditLabel()
+    // message for cancelling editing but it, rather counter-intuitively, keeps
+    // the last text entered in the dialog while cancelling as we do it below
+    // restores the original text which is the more expected behaviour.
+
+    // We shouldn't destroy the control ourselves according to MSDN, which
+    // proposes WM_CANCELMODE to do this, but it doesn't seem to work so
+    // emulate the corresponding user action instead.
+    ::SendMessage(hwnd, WM_KEYDOWN, cancel ? VK_ESCAPE : VK_RETURN, 0);
 
     return true;
 }