Slightly simplify wxChoice::MSWShouldPreProcessMessage()

No real changes, just make this version more consistent with the one in
wxTextCtrl and avoid unnecessary casts.
This commit is contained in:
Vadim Zeitlin
2021-07-23 17:10:34 +01:00
parent 8004002e5e
commit 61ff7de997

View File

@@ -121,21 +121,25 @@ bool wxChoice::Create(wxWindow *parent,
style, validator, name); style, validator, name);
} }
bool wxChoice::MSWShouldPreProcessMessage(WXMSG *pMsg) bool wxChoice::MSWShouldPreProcessMessage(WXMSG *msg)
{ {
MSG *msg = (MSG *) pMsg; if ( msg->message == WM_KEYDOWN )
// 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 (::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 WXDWORD wxChoice::MSWGetStyle(long style, WXDWORD *exstyle) const