PreTranslateMessage()中,判断当前消息发往窗口的句柄

解决方案 »

  1.   

    因为windows系统对CComboBox缺省的处理把VK_RETURN给翻译了,而且是你拿到这个消息之前,所以,你需要在CComboBox::PreTranslateMessage里面添加自己的响应处理代码1. 继承 CComboBox 生成自己的 CMyComboBox
    2. 在PreTranslateMessage处理函数里面,判断如果是回车键,返回TRUEBOOL CMyComboBox::PreTranslateMessage(MSG* pMsg) 
    {
    if( pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN )
    {
    ...
    ...
    return TRUE;
    }
    return CComboBox::PreTranslateMessage(pMsg);
    }