标签:
原文链接: http://computer-programming-forum.com/81-vc/c92ab6e6d6ac92bc.htm
楼主
How to handle the return key on a ClistCtrl ? I‘ve tried to intercept
the LVN_KEYDOWN message but the Return key is not handled !!! I‘ve also
tried to intercept the NM_RETURN message but it doesn‘t work
Thanks in advance.
O.Ferrandiz
2楼
You need to override PreTranslateMessage to trap the WM_KEYDOWN(VK_RETURN)
message like so:
BOOL
CListCtrlEx::PreTranslateMessage(MSG* pMsg)
{
if (((GetStyle() & LVS_EDITLABELS) == 0) || (pMsg->message != WM_KEYDOWN)
|| (pMsg->wParam != VK_RETURN))
return CListCtrl::PreTranslateMessage(pMsg);
// Send the message on to the control
DispatchMessage(pMsg);
return TRUE;
}
Note that you don‘t need to call TranslateMessage() if you only need the
WM_KEYDOWN message, as that function only causes a WM_CHAR(VK_RETURN)
message to be sent to your handler. Now you‘ll get the WM_NOTIFY(NM_RETURN)
messages.
CListCtrl的LVN_KEYDOWN事件中怎么捕捉不到回车键?
标签:
原文地址:http://www.cnblogs.com/huhu0013/p/4691958.html