This question requires an answer that cannot be given in the form of code avoidance, since the Win32 API at the heart of other methods does not allow this. If other methods allow this, they just write the code for you. :)
So the real question is: what is the smallest, neatest way to do this? This worked for me:
Firstly, there is no need to handle WM_KEYDOWN! And there is no need to test the Ctrl key down already. 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 to process WM_CHAR and do Ctrl + A there:
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 (...)
user1418124 Aug 18 '14 at 3:28 2014-08-18 03:28
source share