Question

I made an edit control able to accept data when somebody would click "Enter". I used subclassing to do that. It worked almost perfectly. However after clicking "Enter" the system plays "Error" sound every time. I tried to use ES_MULTILINE and ES_AUTOVSCROLL to bypass it but it helped partially. Now after clicking "Enter" there's no sound, but in the textbox appears useless "Enter" character, that is impossible to delete. How to bypass the system sound? Or delete "Enter" character from that textbox (SetWindowText(handle, "") doesn't help).

Was it helpful?

Solution

You do not need the ES_MULTILINE, ES_AUTOVSCROLL or ES_WANTRETURN style flags.

To stop a single-line edit control from beeping on VK_RETURN you need to handle the WM_CHAR message for that control and return 0 for VK_RETURN without calling the default window procedure, which has to be called for all other keys.

OTHER TIPS

I learned from WinAPI Reference that default processing of WM_CHAR for an edit calls MessageBeep function for an illegal character, such as enter and tab. I had subclassed the edit control to tab between controls by intercepting WM_KEYDOWN (as shown by Petzold for scroll bars), but it was beeping when I pressed tab. So I intercept WM_CHAR to avoid default processing when I press tab, and so stop the beep.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top