Results 1 to 19 of 19

Thread: keyascii ....ctrl+v

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Ca
    Posts
    106

    Question

    how do u catch ctrl+v or ctrl+anything...? I'm trying to see if the user pasted text from another place to my textbox. is there a way that keyascii detects ctrl+...?

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Ca
    Posts
    106
    ok nevermind... i figured it out.. post reply if you want to know

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Ca
    Posts
    106
    is there a way I can access something in clipboard? that is... some string that is copied on to the clipboard..

  4. #4
    Guest
    Here is how to check if something is copied to the clipboard, put it in a Timer if you want to check repeatedly.

    Code:
    Private Sub Command1_Click()
    x = ClipBoard.GetText() 
    If x <> "" Then
    Msgbox "String copied to clipboard: " & x
    Else
    Msgbox "Nothing on the clipboard."
    Exit Sub
    End If

  5. #5
    Addicted Member
    Join Date
    Feb 2000
    Location
    London, UK
    Posts
    145
    xstopx81:
    I would like to know what you found out.
    Please share your wisdom...
    Pentax
    Wilhelm Tunemyr,
    Swede in London

    [email protected]

    "Dort, wo man Bücher verbrennt, verbrennt man am Ende auch Menschen"
    Heinrich Heine (1797-1856)

    Pravda vítezi!
    (Truth prevails!)

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Ca
    Posts
    106
    ok pentax.. this is what i got so far... keyascii detects few keyboard combinations such as ctrl+v or ctrl+x ...etc..
    ascii for those are:

    ctrl+a = 1,
    ctrl+b = 2,
    ctrl+c = 3....

    and so on with alphabetical orders.. which means that ctrl+v = 22... I'm trying to get the text that's copied and pasted to an invisible richtextbox that i have right now... However, when I get the actual text from the clipboard and try to make rtfInvis.textrtf = clipboard.gettext, it comes out as plain... What i mean is that it doesn't come out as bold, underlined, or whatever the original text was...
    hope I could've help and help me on my problem as well.

    xstopx81

  7. #7
    Guest
    xstopx81, when text is copied and then pasted into the RichTextBox, it is just plain text.

    You'd have to make the font bold yourself.

    Code:
    RichTextBox1.SelLength = Len(RichTextBox1.Text)
    RichTextBox1.SelBold = True
    RichTextBox1.SelStart = 0

  8. #8
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    If you use the KeyDown event instead of KeyPress, then the Shift parameter will indicate the status of the shift, ctrl and alt keys. The first bit is a flag for the shift key, the second for ctrl, and the third for alt.

    Basically if Shift = 2, 3 or 6 then the ctrl key is down. So you could have something like this:

    Code:
    Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
    
    If (KeyCode = VbKeyV) And (Shift = 2 Or Shift = 3 Or Shift = 6) Then
       'your code here
    End If
    
    End Sub
    (Oops, just realised I'd written that code wrong and had to edit it)

    [Edited by HarryW on 09-09-2000 at 01:26 PM]
    Harry.

    "From one thing, know ten thousand things."

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Ca
    Posts
    106
    matthew... how will i know whether the copied text was originally bold, underlined, or italic? I must know that before setting it bold myself

  10. #10
    Guest
    The SelBold property is True when the font is bold, or setting the SelBold property to True while it is bold will not do anything to it. If you set it to False, it would make it so it's not bold. But, if it makes you more comfortable:

    Code:
    Private Sub Command1_Click()
    RichTextBox1.SelLength = Len(RichTextBox1.Text)
    If RichTextBox1.SelBold = True Then
    MsgBox "Already bold"
    Else
    MsgBox "Not bold"
    End If

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Ca
    Posts
    106
    I dont think you're getting what I'm talking about.. I'm saying that after the user copies a selected text, and then trys to paste it on another rtf box, how will i know if the text in the clipboard had certain properties...

  12. #12
    Guest
    You don't...but you can let them paste it first, then check it with the SelBold property.

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Ca
    Posts
    106
    the thing is that if i paste it manually, that is using clipboard.gettext, i get plain text even if the clipboard is holding a bold string

  14. #14
    Guest
    This should work...
    Code:
    RichTextBox1.SelRTF = Clipboard.GetText(vbCFRTF)

  15. #15
    Guest
    When you paste from the clipboard to the RichTextBox, it will paste as plain text (don't ask me how AOL Instant Messager does it). But, you'd just do something like this:

    Code:
    Private Sub Command1_Click()
    RichTextBox1.text = ClipBoard.GetText() 
    If RichTextBox1.text <> "" Then
    RichTextBox1.SelLength = Len(RichTextBox1.Text)
    RichTextBox1.SelBold = True
    RichTextBox1.SelStart = 0
    Else
    Msgbox "No text on the clipboard!", vbCritical
    End If
    End Sub

  16. #16
    Guest
    Matthew: Setting the Bold directly from the RTB's Font is about 30 times faster than highlighting the text and setting it to bold.

    Code:
    RichTextBox1.Font.Bold = True

  17. #17
    Guest
    I knew that. But the problem was, I couldn't find it.

    I thought it was:

    Code:
    RichTextBox1.FontBold = True
    Like a regular Textbox, but it didn't work, so I just used the SelLength property.

    Thanks for showing me the way.

  18. #18

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Ca
    Posts
    106
    i think the proper way to paste it and setting it to bold is

    Code:
      richtextbox1.SelBold = True
      ' paste
    nevermind that... hey matthew or megatron... do u guys know how to make richtextbox have both horizontal and vertical at once? i just made the richtextbox have both but doesn't work..

    [Edited by xstopx81 on 09-11-2000 at 06:07 PM]

  19. #19
    Guest
    You mean so it doesn't word wrap? Just set the RightMargin property to some high number.
    Code:
    RichTextBox1.RightMargin = 10000

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