How do I handle "enter" key in a listbox?
-
I have a dialog with two listboxes in it. I want my listboxes to do something when the "enter" key is pressed. The LBN_* messages listed in the ClassWizard are of no help. I tried responding to WM_KEYUP/DOWN messages from the parent dialog, but the didn't work either. How can I know when the user hits "enter" from a listbox?
-
I have a dialog with two listboxes in it. I want my listboxes to do something when the "enter" key is pressed. The LBN_* messages listed in the ClassWizard are of no help. I tried responding to WM_KEYUP/DOWN messages from the parent dialog, but the didn't work either. How can I know when the user hits "enter" from a listbox?
Try handling OnKeyDown (sorry, I forgot the actual message define) Drinking In The Sun Forgot Password?
-
I have a dialog with two listboxes in it. I want my listboxes to do something when the "enter" key is pressed. The LBN_* messages listed in the ClassWizard are of no help. I tried responding to WM_KEYUP/DOWN messages from the parent dialog, but the didn't work either. How can I know when the user hits "enter" from a listbox?
Hi there, I respond to "del" keys in my listviews by handling the KEYDOWN notifications, this solution should also work for listboxes: In your message map add: (you should use LBN_*)
ON_NOTIFY(LVN_KEYDOWN, IDC_LIST_FILES, OnKeydownListFiles)
Add the handler:void CUpdateDlg::OnKeydownListFiles(NMHDR* pNMHDR, LRESULT* pResult) { LV_KEYDOWN* pLVKeyDow = (LV_KEYDOWN*)pNMHDR; if (pLVKeyDow->wVKey == 46) { // Delete key pressed } *pResult = 0; }
Hope this helps ! Alwin -
I have a dialog with two listboxes in it. I want my listboxes to do something when the "enter" key is pressed. The LBN_* messages listed in the ClassWizard are of no help. I tried responding to WM_KEYUP/DOWN messages from the parent dialog, but the didn't work either. How can I know when the user hits "enter" from a listbox?
Override CYourDlg::PreTranslateMessage, check if listbox has the focus and key is Enter, then do whatever you want. Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group