From 61ff7de997038cb67851f7c7917cacb202de9a67 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 23 Jul 2021 17:10:34 +0100 Subject: [PATCH] Slightly simplify wxChoice::MSWShouldPreProcessMessage() No real changes, just make this version more consistent with the one in wxTextCtrl and avoid unnecessary casts. --- src/msw/choice.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/msw/choice.cpp b/src/msw/choice.cpp index 9a760f56d8..4d3e985a4e 100644 --- a/src/msw/choice.cpp +++ b/src/msw/choice.cpp @@ -121,21 +121,25 @@ bool wxChoice::Create(wxWindow *parent, style, validator, name); } -bool wxChoice::MSWShouldPreProcessMessage(WXMSG *pMsg) +bool wxChoice::MSWShouldPreProcessMessage(WXMSG *msg) { - MSG *msg = (MSG *) pMsg; - - // if the dropdown list is visible, don't preprocess certain keys - if ( msg->message == WM_KEYDOWN - && (msg->wParam == VK_ESCAPE || msg->wParam == VK_RETURN) ) + if ( msg->message == WM_KEYDOWN ) { - if (::SendMessage(GetHwndOf(this), CB_GETDROPPEDSTATE, 0, 0)) + switch ( msg->wParam ) { - return false; + case VK_ESCAPE: + case VK_RETURN: + // These keys are needed by the control itself when the + // dropdown list is visible, so don't preprocess them then. + if (::SendMessage(GetHwndOf(this), CB_GETDROPPEDSTATE, 0, 0)) + { + return false; + } + break; } } - return wxControl::MSWShouldPreProcessMessage(pMsg); + return wxControl::MSWShouldPreProcessMessage(msg); } WXDWORD wxChoice::MSWGetStyle(long style, WXDWORD *exstyle) const