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+...?
Printable View
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+...?
ok nevermind... i figured it out.. post reply if you want to know
is there a way I can access something in clipboard? that is... some string that is copied on to the clipboard..
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
xstopx81:
I would like to know what you found out.
Please share your wisdom...
Pentax
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
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
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:
(Oops, just realised I'd written that code wrong and had to edit it)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
[Edited by HarryW on 09-09-2000 at 01:26 PM]
matthew... how will i know whether the copied text was originally bold, underlined, or italic? I must know that before setting it bold myself
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
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...
You don't...but you can let them paste it first, then check it with the SelBold property.
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
This should work...
Code:RichTextBox1.SelRTF = Clipboard.GetText(vbCFRTF)
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
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
I knew that. But the problem was, I couldn't find it.
I thought it was:
Like a regular Textbox, but it didn't work, so I just used the SelLength property.Code:RichTextBox1.FontBold = True
Thanks for showing me the way.
i think the proper way to paste it and setting it to bold is
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..Code:richtextbox1.SelBold = True
' paste
[Edited by xstopx81 on 09-11-2000 at 06:07 PM]
You mean so it doesn't word wrap? Just set the RightMargin property to some high number.
Code:RichTextBox1.RightMargin = 10000