Preventing Ctrl-V

 I'm creating a kind of text editor, and I'm using RichTextBox to make colored text. I want to use my own procedures to copy data to clipboard (for various reasons), so I want to disable the hotkeys (ctrl-v, ctrl-c, etc) to copy/paste/cut from the RichTextBox, how can I do it?
felipesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mcriderCommented:
Put this in the KEYPRESS EVENT... It will filter out the CTL-V and instead do a debug.print.  You can do this with any key... Just make sure you set KeyAscii to 0 as part of the procedure...

    If KeyAscii = 22 Then
        KeyAscii = 0
        Debug.Print "CTRL-V WAS PRESSED"
    End If


Cheers!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mcriderCommented:
Actually what I gave you will work for textboxes not RichTextBoxes... To do the same for RichTextBoxes, to this in the KEYDOWN EVENT:

    If KeyCode = 86 And Shift = 2 Then
        KeyCode = 0
        Shift = 0
        Debug.Print "CTRL-V WAS PRESSED"
    End If


Cheers!
0
mcriderCommented:
By the way, the code for intercepting CTRL-C is:

    If KeyCode = 67 And Shift = 2 Then
        KeyCode = 0
        Shift = 0
        Debug.Print "CTRL-C WAS PRESSED"
    End If


Also in the KEYDOWN EVENT...


Cheers!
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

felipesAuthor Commented:
 This doesn't work!
0
mcriderCommented:
Did you try the keydown event I gave you???
0
felipesAuthor Commented:
 Yes, I Tried in KeyUP, KeyDown and KeyPress.
0
mcriderCommented:
The code I gave you works perfectly on my VB5 system with SP3 installed... What version are you running?
0
mcriderCommented:
Start a new project...

Add a RichTextBox to Form1.

Put the following code in the DECLARATION SECTION of FORM1:

Private Sub RichTextBox1_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 86 And Shift = 2 Then
        KeyCode = 0
        Shift = 0
        MsgBox "CTRL-V WAS INTERCEPTED"
    End If
    If KeyCode = 67 And Shift = 2 Then
        KeyCode = 0
        Shift = 0
        MsgBox "CTRL-C WAS INTERCEPTED"
    End If
End Sub


If this doesn't work, you've got big problems...


Cheers!
0
felipesAuthor Commented:
 Strange, now it works!!! Thanks!
0
mcriderCommented:
Thanks for the points! Glad I could helps!


Cheers!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.