Click to See Complete Forum and Search --> : People this is important (I realy need help)
casparas
Jan 9th, 2000, 01:47 AM
I'm having the presentaition of my program tomorow and i noticed that one thing is not finished. I just must finsh it until tomorow. You are my last chance.
I have 1 textbox
Problem:
I need to make program wich disalows user to copy information from textbox to clipboard.
(I need to make right mouse button and Ctrl+c
keys inactive on this textbox)
I tried to make something like:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 2 Then
KeyAscii = 0
End If
End Sub
But this just doesn't work
Any ideas apricieted
-thank you
------------------
-casparas
novice programer
casparas@metacrawler.com
MicahCarrick
Jan 9th, 2000, 02:16 AM
The way to disable the right click menu is here: http://www.vb-world.net/tips/tip131.html
As for disabling the ctrl+C and ctrl+x functions, keep in mind that the ctrl key and c key can be pressed at different times so long as the ctrl is pressed first and released last. Try this:
Option Explicit
Dim ctrlDown As Boolean
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
'Set ctrlDown to "True" until the KeyUp
'even is called to release it.
If Shift = 2 Then ctrlDown = True
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyC And ctrlDown = True Then
'User pressed ctrl+C ... clear clipboard
Clipboard.Clear
Beep
End If
If KeyCode = vbKeyX And ctrlDown = True Then
'User pressed ctrl+X ... restore text
'and clear clipboard
Text1.Text = Clipboard.GetText
Clipboard.Clear
Beep
End If
'check if ctrl key was released
If Shift = 2 Then ctrlDown = False
End Sub
Good luck!
------------------
Micah Carrick
http://micah.carrick.com
micah@carrick.com
ICQ: 53480225
Clunietp
Jan 9th, 2000, 02:21 AM
Or you could just set the ENABLED property of the textbox to FALSE, or just use a label instead.
KENNNY
Jan 9th, 2000, 04:43 AM
quite :)
just do text1.enabled = false..?
or subclass it and handle the message manually LOL :)
------------------
cintel rules :p
www.cintelsoftware.co.uk
David Laplante
Jan 9th, 2000, 01:33 PM
Or you could just disable the control key on the keydown event:
Private Sub Text1_KeyDown(KeyCode as integer)
'not sure about the constant there... use the help
if KeyCode = vbKeyControl then KeyCode = 0
end sub
To set KeyCode = 0 cancels the key that was pressed....
Crazy D
Jan 9th, 2000, 02:49 PM
Subclass the textbox, catch the WM_COPY message, and return 1 in the subclass (instead of calling the default windowproc).
This works pretty fine (I assume, I used it with the WM_PASTE message)
That's the easiest way.
The other way ic checking if Ctrl+C is pressed, or Ctrl+Insert is pressed.
venkatraman_r
Jan 9th, 2000, 03:35 PM
Hi,
Keep this code in the keypress event of the text box:
Select Case KeyAscii
Case 3
DoEvents
Clipboard.GetText
Clipboard.Clear
MsgBox "You cannot copy items"
Case 22
KeyAscii = 0
End Select
------------
This works well and I hope this is what u need.
Regards,
Venkat.
------------------
venkatraman_r@hotmail.com
ICQ: 45714766
http://venkat.iscool.net
casparas
Jan 10th, 2000, 01:44 AM
Thank you very much everyone
------------------
-casparas
novice programer
casparas@metacrawler.com
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.