I Want to rewrite the function of atcion of Ctrl+V on the richedit control,
If it is impossible, I Want to disable the Ctrl+V, Who could give me some suggestions?Thanks!
What I would have suggested was to simple derive your own class from CRichEditCtrl and then handle the WM_PASTE message. But for some bisarre reasons this does not work for CRichEditCtrl while it works perfectly for CEdit controls. The same happens when I try to intercept WM_COPY message (guess same with WM_CUT).
Maybe someone can elaborate further on this strange behaviour?
Laitinen
Last edited by laitinen; August 2nd, 2007 at 09:08 AM.
I Want to rewrite the function of atcion of Ctrl+V on the richedit control,
If it is impossible, I Want to disable the Ctrl+V, Who could give me some suggestions?Thanks!
One way to disable it, look at the attached sample.
Cheers
If a post helped you dont forget to "Rate This Post"
One easy method to avoid the default behaviour of any key combination is to define an acelerator for that key, create a handler for the accelerator key and to leave the handler function blank.
Thanks to Pravin and Golanshahar for providing possible solutions!
Just to make it clear, I know this is not a big deal at all but it surprises me that I am not able to handle the WM_PASTE, WM_COPY. WM_CUT and so on in the CRichEditCtrl.
Both solutions mentioned above work good for the CTRL+V key combination, but would not work if there was a menu item or contextmenu item that allowed the user to paste text into the control. Therefore it is a mystery to me why you can not solve the whole problem by just handling the WM_PASTE message. To me, this seems like a bug from MS.
Thanks to Pravin and Golanshahar for providing possible solutions!
Just to make it clear, I know this is not a big deal at all but it surprises me that I am not able to handle the WM_PASTE, WM_COPY. WM_CUT and so on in the CRichEditCtrl.
Both solutions mentioned above work good for the CTRL+V key combination, but would not work if there was a menu item or contextmenu item that allowed the user to paste text into the control. Therefore it is a mystery to me why you can not solve the whole problem by just handling the WM_PASTE message. To me, this seems like a bug from MS.
Regards,
Laitinen
I updated my sample code look at the attached project to see how to trap the WM_PASTE message.
Cheers
If a post helped you dont forget to "Rate This Post"
You are actually experiencing the same problem as I did. If you comment out the code you added in PreTranslateMessage, then you would think that you OnPaste handler should be invoked, right? But it is not!! It is invoked when you do an implicit call to the paste member function, but not when you press ctrl+v. Or am I way of out of track here?
You are actually experiencing the same problem as I did. If you comment out the code you added in PreTranslateMessage, then you would think that you OnPaste handler should be invoked, right? But it is not!! It is invoked when you do an implicit call to the paste member function, but not when you press ctrl+v. Or am I way of out of track here?
Laitinen
I think you are confusing with two things here, if you will open Spy++ and check the messages that is being send to the rich edit control you would see that when you press Ctrl+V WM_PASTE message is not being generated!!! Only WM_KEYDOWN/UP for Ctrl + V, and when you call Paste() member function it send the WM_PASTE message and it can be trapped so maybe this is confusing you.
Cheers
If a post helped you dont forget to "Rate This Post"
I think you are confusing with two things here, if you will open Spy++ and check the messages that is being send to the rich edit control you would see that when you press Ctrl+V WM_PASTE message is not being generated!!! Only WM_KEYDOWN/UP for Ctrl + V, and when you call Paste() member function it send the WM_PASTE message and it can be trapped so maybe this is confusing you.
Cheers
What I am confused about is why WM_PASTE is not sent. I dont see any reason why this should differ from a regular CEdit control. Do you?
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.