How to create a Win32 drop-down combo box with a read-only edit control?
win32comboboxreadonly
How can I have a Win32 drop-down combo box with a read-only edit control?
Synthesized Answer
Based on 0 community responses
To achieve a Win32 drop-down combo box with a read-only edit control, you can create a combo box with the CBS_DROPDOWN style and then make the edit control read-only. You can do this by sending a CB_SETEDITSEL message to the combo box to select the entire text, then sending an EM_SETREADONLY message to the edit control. Alternatively, you can subclass the edit control and handle the WM_CHAR message to prevent user input. Another approach is to use the CBS_DROPDOWNLIST style, which inherently makes the edit control read-only as it doesn't allow text editing.
Key Takeaways
Use CBS_DROPDOWN style and make edit control read-only
Subclass edit control to handle WM_CHAR message
Consider using CBS_DROPDOWNLIST style for inherent read-only behavior
Discussion (0 comments)
No comments available in our database yet.
Comments are synced periodically from Hacker News.