From 9d79c176974ebeb0067d5b53c4bf580ff6bc3ff3 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 2 Dec 2011 00:50:29 +0000 Subject: [PATCH] Don't use ListView_CancelEditLabel() as it doesn't work as expected. 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 | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 716fbcaab1..1f06aa3074 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -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; } -- 2.45.2