Original link: http://computer-programming-forum.com/81-vc/c92ab6e6d6ac92bc.htm
Landlord
How do I handle the return key on a ClistCtrl? I ' ve tried to intercept
The Lvn_keydown message but the Return key was not handled!!! I ' ve Also
Tried to intercept the Nm_return message but it doesn ' t work
Thanks in advance.
O.ferrandiz
2 floor
You need to override PreTranslateMessage to trap the WM_KEYDOWN (Vk_return)
Message like so:
BOOL
CListCtrlEx::P retranslatemessage (msg* pMsg)
{
if (((GetStyle () & lvs_editlabels) = = 0) | | (Pmsg->message! = wm_keydown)
|| (Pmsg->wparam! = Vk_return))
Return CListCtrl::P retranslatemessage (PMSG);
Send the message on to the control
DispatchMessage (PMSG);
return TRUE;
}
Note that you don ' t need to call TranslateMessage () If you are only need the
Wm_keydown message, as-function only causes a WM_CHAR (Vk_return)
Message to is sent to your handler. Now you ' ll get the wm_notify (Nm_return)
Messages.
How can I not catch the return key in CListCtrl's Lvn_keydown event?