Results 1 to 13 of 13

Thread: Can't prevent from copy(Forms2.0)**( Resolved)**

  1. #1

    Thread Starter
    Hyperactive Member anita2002's Avatar
    Join Date
    Dec 2001
    Location
    In u'r Heart
    Posts
    482

    Can't prevent from copy(Forms2.0)**( Resolved)**

    Hi all,
    I'm using is forms2.0 text box. And i want to disable the user from copying the text from it..So I used the following code. But this is not working with forms 2.0 text box.
    -----------------------------------------------------------------------------------
    If KeyAscii = 3 Or KeyAscii = 22 Then KeyAscii = 0
    'keyascii=3 : Ctrl +c
    'keyascii=22 : ctrl + v
    Clipboard.Clear
    -----------------------------------------------------------------------------------
    So what can i use here? Help me,
    Anita
    Last edited by anita2002; Jul 2nd, 2002 at 06:40 AM.
    Can't imagine life without VB
    (Various Boyfriends)

  2. #2
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    well first of all it's not a good thing to clear the clipboard
    second, why not just make a LABEL control?
    also, you need to account for 2 keys for the copy thingie
    Copy: control + insert and control + c

    umm why do you want to disable ctrl + V?

    another thing -> even if the keys are disabled the user can right click with the mouse to copy some text. I dont know but there might be some API to disable this....
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    The lycnonix is getting to u Polite.

    Try this

  4. #4
    khalik
    Guest
    as MrPolite suggested it not good to clear clipboard ...
    but still if u wanna do it on mouse.

    clipboard.clear

  5. #5

    Thread Starter
    Hyperactive Member anita2002's Avatar
    Join Date
    Dec 2001
    Location
    In u'r Heart
    Posts
    482
    Thank you Mr Polite, Mendhak, and Khalik..
    But here as I have locked my textbox, automatically the mouse events won't work here. So i don't worry about copying something with mouse..So u'r thread didn't help me Mendhak..
    Now the only issue is how to disable ctrl + c and ctrl +v
    If it is the normal text box the the code which i have given should work. But sinces its a Froms2.0 text box, my code is not working. So please tell me what to do?
    And why it is not good to clear the clipboard?
    Please help.
    Anita
    Can't imagine life without VB
    (Various Boyfriends)

  6. #6
    khalik
    Guest
    Originally posted by mendhak
    The lycnonix is getting to u Polite.

    Try this

    it been long time... Mendhak..
    how about combo box....

  7. #7
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    if you want to show data like a textbox then just make a label with borderstyle to 1, backcolor to white, then use it like a textbox to show text. it will look similar to a textbox in almost all ways.
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  8. #8
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by anita2002
    Thank you Mr Polite, Mendhak, and Khalik..
    But here as I have locked my textbox, automatically the mouse events won't work here. So i don't worry about copying something with mouse..So u'r thread didn't help me Mendhak..
    Now the only issue is how to disable ctrl + c and ctrl +v
    If it is the normal text box the the code which i have given should work. But sinces its a Froms2.0 text box, my code is not working. So please tell me what to do?
    And why it is not good to clear the clipboard?
    Please help.
    Anita
    well the user might have some data on the clipboard and they dont want to clear it eveytime they use your app
    I still dont know why you want to disable ctrl +v. you said it is locked, and ctrl + v is for pasting, you dont need to worry about that. You just need to take care of copying (shortcuts: ctrl + C and ctrl + instert)


    this is how you would detect it:
    VB Code:
    1. Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
    2.     If Shift = vbCtrlMask And (KeyCode = vbKeyC Or KeyCode = vbKeyInsert) Then
    3.          ' Disable it here if you can :D
    4.     End If
    5. End Sub
    dunno how to disable it, I tried KeyCode = 0, but that didnt work
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  9. #9

    Thread Starter
    Hyperactive Member anita2002's Avatar
    Join Date
    Dec 2001
    Location
    In u'r Heart
    Posts
    482
    Originally posted by MrPolite
    well the user might have some data on the clipboard and they dont want to clear it eveytime they use your app
    I still dont know why you want to disable ctrl +v. you said it is locked, and ctrl + v is for pasting, you dont need to worry about that. You just need to take care of copying (shortcuts: ctrl + C and ctrl + instert)


    this is how you would detect it:
    VB Code:
    1. Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
    2.     If Shift = vbCtrlMask And (KeyCode = vbKeyC Or KeyCode = vbKeyInsert) Then
    3.          ' Disable it here if you can :D
    4.     End If
    5. End Sub
    dunno how to disable it, I tried KeyCode = 0, but that didnt work
    Hi,
    Mr. Polite. Thanks for u'r code..
    But the problem is i think here the user presses the "ctrl" and "c" keys simultaneously. How to trace this?
    If nyone able to trace this event then i think it will do with the help of clipboard.clear
    well..i simply added clipbroard.clear in u'r code before the end if statement. So it is working for only "ctrl" key or only "c" key. But not working when the press the "ctrl" and "c" keys simultaneously.
    Please elp me
    Anita
    Can't imagine life without VB
    (Various Boyfriends)

  10. #10

    Thread Starter
    Hyperactive Member anita2002's Avatar
    Join Date
    Dec 2001
    Location
    In u'r Heart
    Posts
    482
    Hi all,
    Can anyone help me???
    Does anyone have some solution?
    Help.....
    Anita
    Can't imagine life without VB
    (Various Boyfriends)

  11. #11
    khalik
    Guest
    Originally posted by anita2002
    Hi all,
    Can anyone help me???
    Does anyone have some solution?
    Help.....
    Anita
    not abetter one...
    onlost focus clear the clipboard....

    by the way pasting may be a problem .. copy may not be a problem to ur app.... if u are able sto[ pasting it ok... think soo

  12. #12

    Thread Starter
    Hyperactive Member anita2002's Avatar
    Join Date
    Dec 2001
    Location
    In u'r Heart
    Posts
    482
    Originally posted by khalik


    not abetter one...
    onlost focus clear the clipboard....

    by the way pasting may be a problem .. copy may not be a problem to ur app.... if u are able sto[ pasting it ok... think soo
    Thanks Khalik,
    But unfortunately clipboard.clear didn't worked on lost focus also. Finally i use clipboard.clear on mousemove event. It worked... Though not a good way..
    Anita..
    Can't imagine life without VB
    (Various Boyfriends)

  13. #13
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Hi again
    The code that I gave you works for Ctrl + C and Ctrl + Instert. The problem was that the data gets copied to the clipboard AFTER you exit the KeyDown sub, so you had to put a DoEvents there. Try this, I tested it and it works
    VB Code:
    1. Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
    2.     If Shift = vbCtrlMask And (KeyCode = vbKeyC Or KeyCode = vbKeyInsert) Then
    3.         ' I think when you use DoEvents, it will copy to clipboard
    4.         DoEvents
    5.         ' Now clear the clipboard
    6.         Clipboard.Clear
    7.     End If
    8. End Sub
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width