Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. [win32]ListView doesn't generate VK_RETURN

[win32]ListView doesn't generate VK_RETURN

Scheduled Pinned Locked Moved C / C++ / MFC
question
13 Posts 5 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Rage

    Ryan Binns wrote: This question is asked so often, I'm disgusted at how many people don't search the forum before asking questions Same for me. If you only knew how many times I've answered the question "How do I change the caption of my window" or "How do I convert my CString into a ..." :~ I think the link to Mike's C++ FAQ should be as big as the advertisement banner, and even that would not help :rolleyes:. ~RaGE();

    R Offline
    R Offline
    Ryan Binns
    wrote on last edited by
    #4

    Rage wrote: If you only knew how many times I've answered the question "How do I change the caption of my window" or "How do I convert my CString into a ..." I can guess. I visit the VC++ forum a few times a day, so I see all the questions. Rage wrote: I think the link to Mike's C++ FAQ should be as big as the advertisement banner, and even that would not help Unfortunately it probably wouldn't. I lot of people who ask questions don't appear to be interested in helping themselves. They just want other people to solve all their problems. Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
    Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"

    1 Reply Last reply
    0
    • R Rage

      Ryan Binns wrote: This question is asked so often, I'm disgusted at how many people don't search the forum before asking questions Same for me. If you only knew how many times I've answered the question "How do I change the caption of my window" or "How do I convert my CString into a ..." :~ I think the link to Mike's C++ FAQ should be as big as the advertisement banner, and even that would not help :rolleyes:. ~RaGE();

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #5

      Rage wrote: I think the link to Mike's C++ FAQ should be as big as the advertisement banner, and even that would not help . My browser blocks banners, ads and popups :~ ;) regards

      R 1 Reply Last reply
      0
      • L Lost User

        Rage wrote: I think the link to Mike's C++ FAQ should be as big as the advertisement banner, and even that would not help . My browser blocks banners, ads and popups :~ ;) regards

        R Offline
        R Offline
        Ryan Binns
        wrote on last edited by
        #6

        Greg S. wrote: My browser blocks banners, ads and popups :rolleyes: Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
        Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"

        M 1 Reply Last reply
        0
        • R Ryan Binns

          Greg S. wrote: My browser blocks banners, ads and popups :rolleyes: Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
          Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"

          M Offline
          M Offline
          Melekor
          wrote on last edited by
          #7

          I posted some replies to your nasty comments but I deleted them. I'm just wasting my time. I don't know why you guys have to be so mean about it, you're so perfectly willing to post degrading comments, even saying that I am not interested in helping myself. Well, HF picking on the newbies guys. Later.

          R 1 Reply Last reply
          0
          • M Melekor

            I posted some replies to your nasty comments but I deleted them. I'm just wasting my time. I don't know why you guys have to be so mean about it, you're so perfectly willing to post degrading comments, even saying that I am not interested in helping myself. Well, HF picking on the newbies guys. Later.

            R Offline
            R Offline
            Ryan Binns
            wrote on last edited by
            #8

            I saw that you weren't using MFC, which is why I gave a non-MFC answer in my reply. It's even easier than if you are using MFC. Every message that is posted to your application is handled through your message loop. If you're not using MFC, then you have complete control over the message loop, so just check every message for a WM_KEYDOWN sent to your list control, with wParam == VK_RETURN. But having said that, this question has been asked recently, for both win32 and MFC. If you had searched the last week's messages, you would have found your answer. Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
            Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"

            1 Reply Last reply
            0
            • M Melekor

              I have a ListView control and I want it to do something when the user presses enter. So, I have put in a case for LVN_KEYDOWN, which seems to work fine for most keys except enter. I never recieve a VK_RETURN in the wVKey member, no matter how much I press the button :wtf: So, is there some style I need to set or something? What do I need to do to be notified when the user presses enter in the ListView control? Thanks, Melekor

              J Offline
              J Offline
              JT Anderson
              wrote on last edited by
              #9

              Are you really sure you want to perform you action based on VK_RETURN? Perhaps you would be better off handling the LVN_ITEMACTIVATE message. -------- There are 10 types of people in this world. Those who know binary and those who don't.

              M 1 Reply Last reply
              0
              • J JT Anderson

                Are you really sure you want to perform you action based on VK_RETURN? Perhaps you would be better off handling the LVN_ITEMACTIVATE message. -------- There are 10 types of people in this world. Those who know binary and those who don't.

                M Offline
                M Offline
                Melekor
                wrote on last edited by
                #10

                I am already handling LVN_ITEMACTIVATE, which only seems to get sent by double-clicks. Thanks anyways though.

                J 1 Reply Last reply
                0
                • M Melekor

                  I am already handling LVN_ITEMACTIVATE, which only seems to get sent by double-clicks. Thanks anyways though.

                  J Offline
                  J Offline
                  JT Anderson
                  wrote on last edited by
                  #11

                  Aha! I was going to set out to prove you wrong about that, but now think I know what your problem is. Your CListCtrl is in a dialog, right? As some of the other responses may have suggested, the dialog is eating your VK_RETURN messages. I suggest that you derive a class from CListCtrl and add a WM_GETDLGCODE handler something like this:

                  UINT CListCtrlEx::OnGetDlgCode()
                  {
                  const MSG *pMsg = (const MSG *)GetCurrentMessage()->lParam;

                  if (pMsg != NULL &&
                      pMsg->message == WM\_KEYDOWN &&
                      pMsg->wParam == VK\_RETURN) {
                       return DLGC\_WANTMESSAGE;
                  }
                  
                  return CListCtrl::OnGetDlgCode();
                  

                  }

                  Assuming that you want the same thing to happen for double-clicks and the enter key, you should handle LVN_ITEMACTIVATE. If you want to do something different, then this change should get the WM_KEYDOWN/VK_RETURN to your list control. -------- There are 10 types of people in this world. Those who know binary and those who don't.

                  M 1 Reply Last reply
                  0
                  • J JT Anderson

                    Aha! I was going to set out to prove you wrong about that, but now think I know what your problem is. Your CListCtrl is in a dialog, right? As some of the other responses may have suggested, the dialog is eating your VK_RETURN messages. I suggest that you derive a class from CListCtrl and add a WM_GETDLGCODE handler something like this:

                    UINT CListCtrlEx::OnGetDlgCode()
                    {
                    const MSG *pMsg = (const MSG *)GetCurrentMessage()->lParam;

                    if (pMsg != NULL &&
                        pMsg->message == WM\_KEYDOWN &&
                        pMsg->wParam == VK\_RETURN) {
                         return DLGC\_WANTMESSAGE;
                    }
                    
                    return CListCtrl::OnGetDlgCode();
                    

                    }

                    Assuming that you want the same thing to happen for double-clicks and the enter key, you should handle LVN_ITEMACTIVATE. If you want to do something different, then this change should get the WM_KEYDOWN/VK_RETURN to your list control. -------- There are 10 types of people in this world. Those who know binary and those who don't.

                    M Offline
                    M Offline
                    Melekor
                    wrote on last edited by
                    #12

                    I'm not using MFC at all and My ListView control is in a mdi child window. So I can't use that code. I did mention I was not using mfc but I didn't mention what kind of parent window the list view was in because I didn't think it was important. Sorry about that. btw Ryan Binns, you edited your answer to say "if you're using win32, just check your message loop". Do you think that answers my question? It doesn't. I admit I didn't search the forum for an answer before, but I have now. And it's not there.

                    J 1 Reply Last reply
                    0
                    • M Melekor

                      I'm not using MFC at all and My ListView control is in a mdi child window. So I can't use that code. I did mention I was not using mfc but I didn't mention what kind of parent window the list view was in because I didn't think it was important. Sorry about that. btw Ryan Binns, you edited your answer to say "if you're using win32, just check your message loop". Do you think that answers my question? It doesn't. I admit I didn't search the forum for an answer before, but I have now. And it's not there.

                      J Offline
                      J Offline
                      JT Anderson
                      wrote on last edited by
                      #13

                      Well, you may not be able to use the code, but you can still use the concept. You can subclass (in the Windows sense, not the C++ sense) the ListView control and handle the WM_GETDLGCODE message. There may be more (seemingly) expedient ways to work around your problem, such as peeking the message loop or playing games with the default button, but I don't know of any ways more correct than handling WM_GETDLGCODE as I suggested. -------- There are 10 types of people in this world. Those who know binary and those who don't.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups