How i can disable CComboBox mfc keyboard navigation, i need when i press key on keyboard with open dropdown list, item must not selecting. Thanks!
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you really just mean: “how do I disable the control from being changed?”, then just call the EnableWindow method on the CComboBox.
But if you really mean you just want to block keyboard messages from hitting the control, then use window subclassing to swallow keyboard messages. (Don’t confuse the term “window subclassing” with C++ classes – not the same thing). Basically, we’re just going to intercept all WM_CHAR and WM_KEYDOWN messages associated with the combo box and let all the other messages pass.
Do this:
Double check to make sure this doesn’t break tab key navigation. I just tried and it seems to work fine. You may not need to swallow WM_CHAR, just might need to swallow WM_KEYUP and WM_KEYDOWN. Some experimentation on your part is likely needed.
There’s also an MFC method on the CWnd class called SubclassWindow. So if you want to go pure MFC, you can look into this as well.