Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

control V 1

Status
Not open for further replies.

flyax63

Technical User
Mar 14, 2001
6
GR
Suppose I don't want to allow users of my program to paste images in a textbox of my program. So I can use in the "mnuEdit_Click" an expression like this:
If not Clipboard.GetFormat(vbCFText) Then mnuPaste.Enabled = false

Still the user can bypass my code and paste an non-text object with ^V. Is it possible to avoid it?
 
Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
If Button = vbRightButton Then
Text1.Enabled = False
Text1.Enabled = True
PopupMenu mnuPopUp

End If
End Sub

it disabeld the standard popup and then show your popup Eric De Decker
vbg.be@vbgroup.nl

License And Copy Protection AxtiveX.

Download Demo version on my Site:
 
Maybe you misunderstood my question, but this is my fault for sure. I wrote 'textbox' but I really meant 'RichTextBox'. Nevertheless you have helped me to solve another problem and you gave me some ideas to improve my program. I really thank you.
Regarding my original question, that was preventing user from pasting non-text objects into a RichTextBox with Control+V key, I tried this

Private Sub richTextBox1_KeyDown(KeyCode As Integer, Shift As Integer)
badPaste = False 'badPaste as boolean
If Clipboard.GetFormat(vbCFText) Then Exit Sub

If Shift = 2 And KeyCode = vbKeyV Then
MsgBox ("Not a valid paste")
badPaste = True
End If
End Sub

It was not quite satisfactory. Pasting is not executed, but a 'v' is written inside the RichTextBox, at the beginning.
 
If Shift = 2 And KeyCode = vbKeyV Then
MsgBox ("Not a valid paste")

badpaste = True
KeyCode = 0

End If
Eric De Decker
vbg.be@vbgroup.nl

License And Copy Protection AxtiveX.

Download Demo version on my Site:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top