[win32]ListView doesn't generate VK_RETURN
-
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();
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" -
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();
-
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
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" -
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"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.
-
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.
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" -
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
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.
-
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.
-
I am already handling LVN_ITEMACTIVATE, which only seems to get sent by double-clicks. Thanks anyways though.
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.
-
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.
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.
-
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.
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.