Keydown event input / return detection in C ++

I am trying to detect in my application if the Enter/ buttons are pressed Return. My problem is that the LVN_KEYDOWN event (indicates that a key is pressed) does not detect the Enter/ key Return.

I saw similar questions for other languages, but cannot find a solution for C ++.

My event for reading a keystroke:

void ListOption::OnLvnKeydownList1(NMHDR *pNMHDR, LRESULT *pResult)
{
    LPNMLVKEYDOWN pLVKeyDow = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR);
    // TODO: Add your control notification handler code here
    if(pLVKeyDow->wVKey == VK_RETURN)
    {
        OnItemActivateList1(pNMHDR, pResult);
        *pResult = 1;
    }
    *pResult = 0;
}

This code works for almost any key, execept for a key Enter.

There is only one button in my dialog box, and the default button is FALSE. How can I detect a keystroke?

: . CImageSheet, CImagePages (). , ( , ).
enter image description here

Enter, , . LVN_ITEMCTIVATE ( ):

+4
1

PreTranslateMessage , ListView. CPropertyPage.

BOOL CMyPropertyPage::PreTranslateMessage(MSG* pMsg)
{
    //optional: you can handle keys only when ListView has focus
    if (GetFocus() == &List) 
    if (pMsg->message == WM_KEYDOWN)
    {
      if (pMsg->wParam == VK_RETURN)
      {
         //return 1 to eat the message, or allow for default processing
         int sel = List.GetNextItem(-1, LVNI_SELECTED);
         if (sel >= 0)
         {
            MessageBox("VK_RETURN");
            TRACE("ListView_GetNextItem %d\n", sel);
            return 1;
         }
         else
            TRACE("ListView_GetNextItem not-selected, %d\n", sel);
      }

      if (pMsg->wParam == VK_ESCAPE)
      {
         //do nothing!
      }
    }

    return CPropertyPage::PreTranslateMessage(pMsg);
}
+3

All Articles