No need to handle WM_KEYDOWN! I know that most of the examples here (and CodeProject and many others) all say that there is, but it does not cure the audio signal that occurs whenever a WM_CHAR that is not processed occurs.
Instead, try the following:
LRESULT CALLBACK Edit_Prc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam){ if(msg==WM_CHAR&&wParam==1){SendMessage(hwnd,EM_SETSEL,0,-1); return 1;} else return CallWindowProc((void*)WPA,hwnd,msg,wParam,lParam); }
Remember to subclass the EDIT control to this Edit_Prc () using WPA = SetWindowLong (...), where WPA is the address of the window procedure for CallWindowProc (...)
I understood this from an experiment, finding that all the answers I found on the Internet insisted on processing WM_KEYDOWN using GetKeyState (), and ended up with a great code that could not stop this annoying beep!
While this answer does not apply to dotnet, in such cases it is usually better to cut into the pursuit and solve it, and not be tormented by which version of the large code wrapping system may or may not do this for you, especially if you want to avoid the risk of dealing with inline behavior.
user1418124 Aug 18 '14 at 3:38 a.m. 2014-08-18 03:38
source share