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!
Printable View
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!
That is a very good question forester!
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
One way to disable it, look at the attached sample.Quote:
Originally Posted by forester
Cheers
Hello,
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.
Regards,
Pravin.
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
Quote:
Originally Posted by laitinen
I updated my sample code look at the attached project to see how to trap the WM_PASTE message.
Cheers
Hi Golan!
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 learn a lot, Thanks for your replies! I will test to see which one works better!
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. ;)Quote:
Originally Posted by laitinen
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? :confused:Quote:
Originally Posted by golanshahar
Thanks for great help!
Laitinen
Well i have no idea why its differ :D, But, this is what Spy++ shows...Quote:
Originally Posted by laitinen
Cheers