Reputation: 449
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).
Upvotes: 4
Views: 1661
Reputation: 31
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.
Upvotes: 3
Reputation: 32334
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.
Upvotes: 5