1 Attachment(s)
VB6 - RichTextBox: Disabling Cut, Copy & Paste
Hai friends,:)
Here is a solution to the common problem of disabling cut, copy and paste in a RichTextBox Control.
I had found it after certain experiments...:):bigyello:
I hope, you all will like it..:);)
Below is the code:
Code:
'Created by Akhilesh B Chandran
Private Sub RichTextBox1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 45 And Shift = 1 Then KeyCode = 0 'paste(shift + insert)
If KeyCode = 45 And Shift = 2 Then KeyCode = 0 'copy(ctrl + insert)
If KeyCode = 86 And Shift = 2 Then KeyCode = 0 'paste(ctrl + v)
If KeyCode = 67 And Shift = 2 Then KeyCode = 0 'copy(ctrl + c)
If KeyCode = 88 And Shift = 2 Then KeyCode = 0 'cut(ctrl + x)
End Sub
Note: You have to set the AutoVerbMenu property of the Richtextbox control to False(for disabling the popup menu on right click)
Please post your comments and suggestions...:)
-Regards :)
Akhilesh B Chandran
Re: VB6 - RichTextBox: Disabling Cut, Copy & Paste
I can still copy, cut and paste using the keyboard.
Just use 3 keys instead of 2, Control+Shift+The_Key
Not sure is this any better or not? >
Code:
Option Explicit
Private CntrlKey As Boolean
Private Sub RichTextBox1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyControl Then
CntrlKey = True
End If
Select Case KeyCode
Case vbKeyZ, vbKeyX, vbKeyC, vbKeyV, vbKeyInsert
If CntrlKey = True Then KeyCode = 0
End Select
If (Shift And vbShiftMask) And vbKeyInsert Then
KeyCode = 0
End If
End Sub
Private Sub RichTextBox1_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyControl Then
CntrlKey = False
End If
End Sub
Re: VB6 - RichTextBox: Disabling Cut, Copy & Paste
I didnt know that it was possible with 3 keys. Thanks for the code:)
Re: VB6 - RichTextBox: Disabling Cut, Copy & Paste
another thing to paste
A
1) click on the textbox
2) shift + F10
3) click paste
B.
1) right click on the textbox
2) click on paste
Re: VB6 - RichTextBox: Disabling Cut, Copy & Paste
Quote:
Originally Posted by
youquijano
another thing to paste
A
1) click on the textbox
2) shift + F10
3) click paste
B.
1) right click on the textbox
2) click on paste
We are discussing about Richtextbox :) And we have disabled the AutoVerbMenu (see post #1). So, no problem with that ;)
Re: VB6 - RichTextBox: Disabling Cut, Copy & Paste
my bad. but im asking for textboxes on how to disable them
Re: VB6 - RichTextBox: Disabling Cut, Copy & Paste
Quote:
Originally Posted by
youquijano
my bad. but im asking for textboxes on how to disable them
Did you tried searching this forum ? I think, it has been asked for several times. :)