Catching key strokes in a ListView

This is a discussion on Catching key strokes in a ListView within the Windows Programming forums, part of the Platform Specific Boards category; So I've been lurking around the MSDN more now, and their information on how to catch key strokes in a ...

  1. #1
    Registered Abuser
    Join Date
    Jun 2006
    Location
    Toronto
    Posts
    591

    Catching key strokes in a ListView

    So I've been lurking around the MSDN more now, and their information on how to catch key strokes in a ListView is pretty straight forward: Simply catch the LVN_KEYDOWN notification from the WM_NOTIFY message and you're all set... Except for one thing: I can't seem to catch "enter" key strokes. Here is the code:
    Code:
    case LVN_KEYDOWN:
    {
        switch(((NMLVKEYDOWN *)lParam)->wVKey)
        {
              case VK_RETURN:
              {
                   displaySelected(((NMHDR *)lParam)->hwndFrom);
                   break;
              }
              default:
                   return DefWindowProc (hwnd, message, wParam, lParam);
        }
        break;
    }
    It catches just about every other key stroke without problem. I tested this by putting a messageBox right after the "case LVN_KEYDOWN"; it would pop up as expected for almost every key except the return key.
    Does anyone know why this is? is there some special case/keycode that I am not aware of when catching the return key?
    Thanks for any insight you can give me.

  2. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    329
    Why don't you subclass the listview, and catch the keystrokes through that.
    I always do that, and it works fine..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 11-23-2007, 01:48 PM
  2. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  3. Directional Keys - Useing in Console
    By RoD in forum C++ Programming
    Replies: 38
    Last Post: 10-06-2002, 05:42 PM
  4. FAQ: Directional Keys - Useing in Console
    By RoD in forum FAQ Board
    Replies: 38
    Last Post: 10-06-2002, 05:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21