Use ListView_CancelEditLabel() to implement wxListCtrl::EndEditLabel().

Windows XP and later finally added a special message to cancel label editing,
use it if available.

Also improve the documentation of this method.

See #7663.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64374 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-05-21 13:17:25 +00:00
parent f2b504977d
commit 417b8fcc49
2 changed files with 22 additions and 5 deletions

View File

@@ -1561,10 +1561,21 @@ bool wxListCtrl::EndEditLabel(bool cancel)
if ( !hwnd )
return false;
// 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 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);
}
return true;
}