felipes
asked on
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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!
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!
ASKER
This doesn't work!
Did you try the keydown event I gave you???
ASKER
Yes, I Tried in KeyUP, KeyDown and KeyPress.
The code I gave you works perfectly on my VB5 system with SP3 installed... What version are you running?
Start a new project...
Add a RichTextBox to Form1.
Put the following code in the DECLARATION SECTION of FORM1:
Private Sub RichTextBox1_KeyDown(KeyCo de 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!
Add a RichTextBox to Form1.
Put the following code in the DECLARATION SECTION of FORM1:
Private Sub RichTextBox1_KeyDown(KeyCo
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!
ASKER
Strange, now it works!!! Thanks!
Thanks for the points! Glad I could helps!
Cheers!
Cheers!
If KeyCode = 86 And Shift = 2 Then
KeyCode = 0
Shift = 0
Debug.Print "CTRL-V WAS PRESSED"
End If
Cheers!