-
1 Attachment(s)
Inserting Hyperlinks
In addition to turning a URL you enter into a hyperlink (as in "Auto Detect and respond to URLs" above) you can turn ordinary text into hyperlinked text that points to a URL of your choice.
To do this the text in the Richtextbox has to have its link notification turned on. Then, as before, the form containing the Richtextbox has to be subclassed so that you can respond to user actions. I've created a class that simplifies these tasks.
This class has two events:Clicked - raised when user clicks a hyperlink.
MouseMove - raised when the user moves the mouse over a hyperlink
And three methods
Initialize - called once to attach the RTB to the hyperlink class
InsertHyperlink - can hyperlink selected text or insert new text and hyperlink it.
RefreshHyperlinks - Unfortunately, whenever the richtextbox's TextRTF property is changed, the RTB will lose all link notification information. To remind the RTB of previously hyperlinked text you must call this method each time the textRTF property is changed.
Here is an example of how to use the class
Code:
'instantiate and initialize the class
Dim Hypertext As clsHyperText
Set Hypertext = New clsHyperText
Hypertext.Initialize RTB
'hyperlink the word "this" in the Richtextbox
RTB.Find ("this")
Hypertext.InsertHyperlink ("http://www.vbforums.com")
To respond to user action on the hyperlinks, simply place code in the events.
Code:
Private Sub Hypertext_Clicked(Button As Integer, URL As String, UnderlyingText As String)
'launch the browser here
If Button = vbLeftButton Then
ShellExecute 0&, "OPEN", URL, vbNullString, "C:\", SW_SHOWNORMAL
Else
'popup menu?
Debug.Print URL, UnderlyingText
End If
End Sub
Attached is a demo project which contains the class.
-
1 Attachment(s)
Insert Animated images
Here is a control that shows you how to add animated GIF images to a Richtextbox. This control was built to replace VBCode smilie tags with their corresponding animated images. It takes advantage of my VB GIF Animator Control and the PictureToRTF function in my above post Insert Pictures.
I placed this functionality on a usercontrol because it uses a timer and an array of picture boxes. The GIFs cannot by placed into the richtextbox transparently, so I change the background of each image to match the background color of the RTB.
The control has two propertiesBackColor - set this property to the backcolor of your Richtextbox to simulate transparency. This property can only be set from code and cannot be changed once pictures have been inserted into the RTB.
FrameInterval - This interval in ms, affects the speed of the animation.
two methodsLoadIcon - load a GIF file and its corresponding tag into the control
ReplaceTags - Replaces each tag in the Richtextbox text with its corresponding animated image.
and one eventNextFrame - Raised at each frame advance interval.
The following is an example of how you might initialize the control
Code:
'set the picture backgrounds to match the RTB background
GIF.BackColor = RTB.BackColor
'load some icon files along with the corresponding tags
Path = App.Path & "\icons\"
With GIF
.loadIcon ":)", Path & "smile.gif"
.loadIcon ":(", Path & "Frown.gif"
.loadIcon ":o", Path & "redface.gif"
.loadIcon ":D", Path & "BigGrin.gif"
End With
Now to replace all the tags in the RTB text with the proper smilie
Code:
GIF.replaceTags RTB
Attached is a demo project which illustrates the proper use of this control.
-
Re: RichTextBox Tricks and Tips
I've got a problem with insertion of rtf, when the text in the target rtb control is colored and the text/rtf being inserted has some colors also, when inserted the color of the inserted rtf is lost... :-( Any workarounds there? :-)
-
Re: RichTextBox Tricks and Tips
what do you mean by "insertion of rtf"?
-
Re: RichTextBox Tricks and Tips
Using your function to insert. :-) For instance, if the target rtb control got some colored text then the rtf being inserted got some colored text also, the color of the rtf being inserted is overridden, the color table is not updated... :-(
-
Re: RichTextBox Tricks and Tips
what you're saying still does not make sense to me.
what do you mean by my function to insert :-) ?
Do you mean inserting an animated GIF? If so then how can that have colored text?
Please explain in detail or supply example code.
-
Re: RichTextBox Tricks and Tips
I think he just means that if for example a RichTextBox is red and you pasted red text into it the text could not be seen.
-
Re: RichTextBox Tricks and Tips
Quote:
Originally Posted by moeur
what you're saying still does not make sense to me.
what do you mean by my function to insert :-) ?
Do you mean inserting an animated GIF? If so then how can that have colored text?
Please explain in detail or supply example code.
For example, the ff. is the tex of the target rtb: dee-u
And the text being inserted is: moeur
If you will try to insert the rtf of moeur to the rtf of dee-u then the colors of meour is not preserved, it is being overridden. Clear now? :-)
-
Re: RichTextBox Tricks and Tips
Not clear,
I still don't know how you are trying to insert text.
why don't you just show me the code you are using to insert text?
-
Re: RichTextBox Tricks and Tips
Ok, here is further explanation since I don't have VB6.0 here.
RichTextbox1 control has the 'dee-u' text (with the colors as in my previous post), RichTextbox2 control has the 'moeur' text (with the colors as in my previous post), get the TextRTF of Richtexbox1 then insert it, using your function to insert rtf, in the RichTextbox2, perhaps in the middle of 'm' and 'o'.... The color of 'dee-u' will be overriden... :-(
I hope I made myself clear already.... :-)
-
Re: RichTextBox Tricks and Tips
After asking 3 times.
I give up.
If you want to supply code mabye I can help.
-
1 Attachment(s)
Re: RichTextBox Tricks and Tips
Ok, have a look at the attached form... :-)
-
Re: RichTextBox Tricks and Tips
works ok for me.
Maybe you have an outdated version of the Richtextbox control.
-
Re: RichTextBox Tricks and Tips
When you click the button and move "dee-u" to rtb2, dee-u takes on the colors of rtb2 rather than maintaining the colors it had in rtb1.
-
Re: RichTextBox Tricks and Tips
Quote:
Originally Posted by MartinLiss
When you click the button and move "dee-u" to rtb2, dee-u takes on the colors of rtb2 rather than maintaining the colors it had in rtb1.
Yup, that is what I am trying to tell... :)
-
Re: RichTextBox Tricks and Tips
The simplest way to do what you want to do is this
Code:
RTB2.SelRTF = RTB1.TextRTF
-
Re: RichTextBox Tricks and Tips
Moeur, thanks for all of this, it's great and alot of it is what I have been looking for, although I don't confess to totally understand all of the code.
I am working through it slowly. ;)
I have used the hyperlink code and there are a couple of question I have:
Firstly, I would only like to enable the autourldetect under certain circumtances. How can I turn it off?
Secondly, if there is a link in the RTB, if I click anywhere in the RTB it opens the link. Is this how you planned it?
I have other text in the RTB which I would be editing and when I click somewhere in the RTB, it opens the link.
If the non-link text is first in the RTB it's ok, but if I click anywhere after the link, where there is no text, just space, it still selects the link and opens the link.
I hope you can follow what I am trying to explain. :rolleyes:
I have just done a straight copy of your code in the example project, with the exception of this line which is not in the Form_Load, but in a treeview node_click.
vb Code:
EnableAutoURLDetection RTB
-
Re: RichTextBox Tricks and Tips
I have now used the following to turn off the detection.
I just wondered, being new to subclassing, is this ok, or do I need anything else.
It seems to work ok. :D
vb Code:
Public Sub DisableAutoURLDetection(rtb As RichTextBox)
Set FormSubClass = Nothing
End Sub
-
Re: RichTextBox Tricks and Tips
try this instead
Code:
Public Sub DisableAutoURLDetection(RTB As RichTextBox)
'disable auto URL detection
SendMessage RTB.hwnd, EM_AUTOURLDETECT, 0&, ByVal 0&
'turn off subclassing
FormSubClass.Unsubclass
End Sub
As to your other problem:
I only see this when the hyperlink is the very last text in the richTextBox. This is a bug in the richtextbox itself. To eliminate this problem, put something after the hyperlink even just a new line.
-
Re: RichTextBox Tricks and Tips
Quote:
Originally Posted by moeur
try this instead
Code:
Public Sub DisableAutoURLDetection(RTB As RichTextBox)
'disable auto URL detection
SendMessage RTB.hwnd, EM_AUTOURLDETECT, 0&, ByVal 0&
'turn off subclassing
FormSubClass.Unsubclass
End Sub
As to your other problem:
I only see this when the hyperlink is the very last text in the richTextBox. This is a bug in the richtextbox itself. To eliminate this problem, put something after the hyperlink even just a new line.
Thanks moeur.
I will change the Disable code.
Is this to change the message from the RTB back to, I guess the form?
I eventually realised that the way to do this was to put the link first, then the text afterwards. :D
Thanks for all your hard work.
-
Re: RichTextBox Tricks and Tips
I am trying to adjust you code to make it an option that can be turned on/off.
If the user opens the Options form and changes the option from Enabled to Disabled, I am getting the error:
Object variable or With block variable not set.
on this line:
I know what this means, but I'm not too sure how to change this.
This is because, even if the Enabled option is selected, I don't use this line until certain conditions are met:
vb Code:
EnableAutoURLDetection RTB
so the RTB hasn't yet been subclassed.
Is there some way of checking if the subclassing has happened before I fire this line of code?
Such as
Code:
If Not FormSubClass.Unsubclass Then ....
-
Re: RichTextBox Tricks and Tips
Actually there is a very simple solution:
Take the line
Code:
Set FormSubClass = New clsSubClass
from out of the EnableAutoURLDetection subroutine and put it into the Form_Load Event.
-
1 Attachment(s)
Re: RichTextBox Tricks and Tips
Hi
I am very new to VB6 so please bear with me.
I have used your Auto URL Detection within my program. When i downloaded your file it worked fine on its own, but as soon as I have intergrated it with mine I seem to have broken it.
My program still work as it did, and the url changes to a hyperlink where expected, the only bit which does not work is th clicking of the url.
Can you look over what I have done and see what you make of it
Thanks
-
Re: RichTextBox Tricks and Tips
http://www.vbforums.com/attachment.p...id=47243&stc=1
I can't run your project because MISUIUtilities.ocx, modCallBack.Bas and clsSubclass are missing from the zip file.
-
Re: RichTextBox Tricks and Tips
Sorry
Give me a couple of minutes and i'll repost with them
-
Re: RichTextBox Tricks and Tips
If MISUIUtilities.ocx is something that you purchased then you shouldn't post it.
-
Re: RichTextBox Tricks and Tips
Martin
Thanks for your offer of help. What a great site you have got here.
I have rewritten this part of my program in a single form removing it from my main program in order to send to you for help and in so, I have resolved my issue.
I have changed my program to look at the SQL Northwind default database. If you change a couple of the records within the orders table on the "Shipname" field to be a url then this seems to work fine.
I have attached for others to view.
If you are going to look at the attached please be aware that my coding maybe a little rough around the edges
-
1 Attachment(s)
Re: RichTextBox Tricks and Tips
-
Re: RichTextBox Tricks and Tips
I just wanted to add my thanks for some really great tips and also to point out that in post #3, line 8 of SetSuperScript is:
.SelText = Chr(&H9D) & .SelText & Chr(&H80)
However, unless I change this to:
.SelText = Chr(&H9D) & .SelText & Chr(&H81)
It behaves strangely.
Thanks again
-
Re: RichTextBox Tricks and Tips
Thank you for these great RTB tips. I have been using the Tables code you provided. As I'm sure you're aware, there are two basic wrappers for RTB control... riched32.dll and riched20.dll. The tables code behaves differently depending on the wrapper being used. The problems I've noted are:
1. Text that wraps in a cell does not display properly if riched32.dll (default) is being used. It displays correctly with the newer riched20.dll (ver 4+).
2. The grid lines of a table created with your code does not print with riched20.dll but does with the older riched32.dll.
Since MS WordPad uses the riched20.dll (disguised as msftedit.dll) and since the tables format correcly, I too prefer that version. My question is... is there a way to have the grid lines print?
Thanks, again for your insight and very helpful code!
Tom
-
2 Attachment(s)
Re: Full Featured Spell Checker
Quote:
Originally Posted by moeur
Here is a class that provides full spell checking functionality for the RichTextBox. This class has only two methods:GetSpellingErrors checks the spelling in all the text of a RTB and returns the number of spelling errors found and marks then all. A right-click on any error brings up a popup menu with suggested changes. If the user selects a change from the menu, then the replacement is made.
ClearSpelling clears all the marked errors.
Here is an example of use:
Code:
Option Explicit
Private SpellCheck As clsSpellCheck
Private Sub cmdSpellCheck_Click()
SpellCheck.GetSpellingErrors RTB
End Sub
Private Sub cmdStopSpell_Click()
SpellCheck.ClearSpelling
End Sub
Private Sub Form_Load()
Set SpellCheck = New clsSpellCheck
RTB.LoadFile App.Path & "\recipe.rtf"
End Sub
This code also provides an example of several other things.
- How to implement the EN_LINK notification function of the RichTextBox. This notification is usually used to mark hyperlinks and respond to mouse events over them. I use it to mark spelling errors and to bring up a popup menu of spelling suggestions for the user to select from.
- I have included a class that is used to create and respond to popup menus. I put this functionality into a class because I wanted all the spell checking functionality contained within a class with none of the code in the form.
- Also included is my "Cute Little Subclasser" class. I use this class whenever I want subclassing capabilities. When this class is declared WithEvents, the user can write code to respond to Windows messages within the form or class's own module. It also is a little more stable than doing your own subclassing since it always remembers to turn itself off.
Attached is the source code for all the above mentioned items PLUS a free mispelled recipe!
Hi there, wanted to try your spell checker but faced some strange issues. I copied over your libraries and imported your form, but for the same actions I am getting error at GetSpellingErrors()
For Each spError In WordDoc.SpellingErrors
Error 13 Type mismatch
whenever there is a misspelled word. If there are no errors, the program works fine. This error only happens to the new 'copied' project, does not happen in your program.
I have added the components and references, even the dll even though I don't think that is needed. I have added the error image attachment here for clearer understanding (if I had not made myself clear)
Am I missing something?
-
Re: Inserting Hyperlinks
Dear all,
Has anyone deviced any method / subclass trick for actually changing the default blue color of the RTF EN_LINK hyperlinks? I mean, if I want to display a red hyperlink, is this possible?
In my research I tried using GetSystemColors and SetSystemColors with index value 26 (Hyperlink) but it seems to have no affect of RichEdit.
-
Re: RichTextBox Tricks and Tips
Hello!
Thank you very much for the code for the tables in richtextbox, it's the only available on the internet. Unfortunatly i'm using vb.net 2005 and can't convert it correctly to use it in my app. Do you have any library for .net?
Regards
-
Re: RichTextBox Tricks and Tips
Hi moeur,
I ran into an issue. If I enable the autourldetection the selchange event doesn't fire so the line and columns dont get updated in the statusbar as I move the cursor
-
Re: RichTextBox Tricks and Tips
I did verify the problem you see. This is a problem with the Richtext box which we have no control over. But, there is a simple fix:
Place the code that is in the SelChange Event in both the RTB_Click and RTB_KeyUp events.
-
Re: RichTextBox Tricks and Tips
Hi moeur
Your code is great for inserting pictures into the rich textbox.
However, i am able to move the images around and resize them. I dont want them to be resized/moved around.
How can you stop pictures from being moved and resized?
(NOTE: The locked property of the rich textbox is useless to me, because if Locked is set to TRUE, then you cant even type in the rich textbox).
-
Re: RichTextBox Tricks and Tips
Hi moeur,
I think you can solve a little problem for me, back in May last year and in another Forum, I was struggling to help someone who wanted something like a ProgressBar but with text inside it (they were building a Browser and wanted to do like Firefox, I think, the Progress was displayed where the URL was typed.) Anyway, I came up with a RichTextBox solution:
Code:
Option Explicit
'
' Example of manipulating RTF in a RichTextBox
' to simulate a 'ProgressBar' with imbedded text
' (Based on some code I found on the Internet somewhere)
'
' Requires:
' Command Button (cmdGo)
' RichTextBox (rtb1)
' Timer (Timer1)
'
' Tested on XP SP2 and it seems to work OK
' Tested on Windows ME and doesn't work
'
Private boFinished As Boolean
Private strOriginalRTF As String
Private Sub cmdGo_Click()
'
' Simulates starting something going
'
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 500
rtb1.Text = "This is some text"
End Sub
Private Sub Timer1_Timer()
'
' Simulates 'progress'
' Triggers once every half second
'
boFinished = UpdateProgress(1)
If boFinished = True Then
Timer1.Enabled = False
rtb1.TextRTF = strOriginalRTF
rtb1.SelStart = 0
rtb1.SelLength = 0
End If
End Sub
Private Function UpdateProgress(intColour As Integer) As Boolean
'
' Progressively change the background colour of
' each character in the RichTextBox to intColour
' Achieved by inserting RTF codes to define a ColorTable
' and highlight the selected text.
'
' Returns True when all characters have been processed
'
Dim strColour As String
Dim strRTF As String
Static intEnd As Integer
UpdateProgress = False
'
' Save the original TextRTF so it can be
' re-set later, increment the character position
' and check if we've finsihed yet
'
If intEnd = 0 Then strOriginalRTF = rtb1.TextRTF
intEnd = intEnd + 1
If intEnd <= Len(rtb1.Text) Then
'
' Select the appropriate number of characters
' and make sure they don't appear highlighted
' by the selection
'
rtb1.SelStart = 0
rtb1.SelLength = intEnd
rtb1.SelColor = rtb1.BackColor
'
' Convert the colour to RGB form
' and insert leading zeros if required
'
strColour = Hex(QBColor(intColour))
strColour = String(6 - Len(strColour), "0") & strColour
'
' Now build our RTF:
'
' ColorTable:
'
strRTF = "{{\colortbl;"
strRTF = strRTF & "\red" & CInt("&H" & Right(strColour, 2))
strRTF = strRTF & "\green" & CInt("&H" & Mid(strColour, 3, 2))
strRTF = strRTF & "\blue" & CInt("&H" & Left(strColour, 2))
strRTF = strRTF & ";}"
'
' Highlight:
' This is the RTF Code used to cause the change in
' colour. It uses our ColorTable (Number 1)
' (I can't seem to find any documentation on this
' code but if it works then ....)
'
strRTF = strRTF & "\highlight1 "
'
' Finally the actual text and closing RTF brackets
'
strRTF = strRTF & Mid(rtb1.Text, 1, intEnd)
strRTF = strRTF & "}}"
'
' Set the RTF of the selected characters to our
' codes
'
rtb1.SelRTF = strRTF
Else
'
' We've finished
'
UpdateProgress = True
intEnd = 0
End If
End Function
Was it, perhaps some of your code I stumbled upon. The 'highlight' thing has had me confused for a long time !!
-
Re: Insert Pictures
Thanks so much for posting these helpful RTB functions. I would like your permission to use modRTFpic.bas in a commercial application. How would you like me to credit you in the comments?
-
Re: Insert Pictures
Quote:
Originally Posted by brianbird
Thanks so much for posting these helpful RTB functions. I would like your permission to use modRTFpic.bas in a commercial application. How would you like me to credit you in the comments?
This was posted in 2007, so he might not still be active, plus since he posted it here he is giving everyone permission to use it, its open.
So give him credits if you want but its not required - at least i dont think so
-
Re: RichTextBox Tricks and Tips
I have a unique question that may compliment this thread.
I need to highlight a line in a richtextbox only if "line starts with" mystring...
The code needs to fire as user is typing...
I store my search strings and unique highlight colors thus:
Code:
Dim searchword() As String = {"fox", "dog", "cat", "horse"}
Dim ItemBkColor() As Color = {Color.Yellow, Color.LightYellow, Color.PaleVioletRed, Color.LightSeaGreen}
Please can you show me how to code the richtextbox events to catch this scenario ?
Thanks
-
Re: RichTextBox Tricks and Tips
The code in this thread refers to VB6 while you seem to be asking about VB.Net.
-
Re: RichTextBox Tricks and Tips
hi moeur i am using your modRTFpic.bas in my server/client to handle smilies.it is working fine in the send part but while receiving i get a code such as
Code:
{\pict\wmetafile8\picw503\pich503\picwgoal285\pichgoal285
010009000003fe0200000000dd02000000000400000003010800050000000b0200000000050000
000c0213001300030000001e00dd02000040092000cc0000000000130013000000000028000000
130000001300000001000800000000007c01000000000000000000000000000000000000217b9c
00297b9c001842a5002142a500a5a5a500ada5a500a5ada5002142ad00a5a5ad002952b500298c
b5004a94b5005294b5003963bd002994bd00319cbd00639cbd0063a5bd006ba5bd00bdbdbd00bd
c6bd00c6c6bd002994c60063adc6006badc600bdc6c600c6c6c6009cbdce00cecece00d6cece00
21a5d60029a5d60029add6006bb5d60094bdd6009cbdd6009cc6d60029a5de0021adde0029adde
009ccede00a5cede0031a5e70029ade70021b5e70031b5e70031bde7006bbde70039c6e700c6de
e700cedee70021b5ef0029b5ef0029bdef0031bdef0029c6ef0052c6ef0073ceef007bceef00ad
d6ef00c6d6ef00addeef00cee7ef0018b5f70021b5f70021bdf70031c6f70052c6f70073c6f700
39cef70073cef70031d6f70039d6f7007bd6f700addef7007be7f700cee7f70031ceff0042ceff
0031d6ff0039d6ff0042d6ff0039deff0042deff00addeff0042e7ff004ae7ff00ade7ff00b5e7
ff004aefff0052efff00b5efff00ceefff00d6efff004af7ff0052f7ff005af7ff00d6f7ff00de
f7ff00f7f7ff005affff00d6ffff00f7ffff00ffffff00ffffff00ffffff00ffffff00ffffff00
ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff
00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffff
ff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ff
ffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00
ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff
00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffff
ff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ff
ffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00
ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff
00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffff
ff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ff
ffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00
ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff
00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffff
ff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff00ff
ffff00ffffff006767676667663e29180b12243266666767676700676767673e211f2533342b1e
16103167676767006767663b203503030303030303200a236667670067673d2d42031367671c67
671303400f1b676300675c2d5003671367671c6767136703400e3c67006644480304671367671c
6667136708032711630061370304041413131c1c1c1315130404030e32004a5003670467146767
1c676613670467031f22003953036705671367671c676713670467032b12003859036704661367
671c66671367046703330c0049560d030303030303030303030303030934180057532a5f5f5a5a
605a5a59555252484d0d20280062505a606060605a5f5a5a5a5556534d421f3e00664956605201
0101115f110101013050362166006761485f016060605e5a5a5a55560150204c67006767585360
60605f605f5a595655532e3b6767006767665848595f605f5a595a55512e3d6766670067676766
61494e56565a594845395c6767676600666767676763614a49383a4a5d63676766676700040000
002701ffff030000000000
instead of the smileys ..where am i going wrong ?:s
-
Re: RichTextBox Tricks and Tips
I would have to see the relevant sections of your code to be of any help.
-
Re: RichTextBox Tricks and Tips
Quote:
Originally Posted by moeur
I would have to see the relevant sections of your code to be of any help.
here , i have uploaded a rough project . i can send smileys from my server to the client and out put them on a textbox but when i send smileys and a message together i am not able to output smileys:(
-
Re: RichTextBox Tricks and Tips
Sorry,
I don't see where you are using my code.
Perhaps you should talk to the hand.
-
Re: RichTextBox Tricks and Tips
Quote:
Originally Posted by moeur
Sorry,
I don't see where you are using my code.
Perhaps you should talk to the hand.
i got it solved (a silly mistake) .A big thanks to you, as this post got me started and i learned a lot from this post and your project as well ..all in all i got so confused i uploaded a different project .sorry .
lastly ,
great work
:thumb: :wave:
-
Re: RichTextBox Tricks and Tips
Is there anyway to change the color of the link?
-
Re: RichTextBox Tricks and Tips
-
Re: RichTextBox Tricks and Tips
moeur, thanks for all your work and these valuable tips.
I am trying to create a module which will actually create a RTF file (document).
To do this, I am writing RTF control words and codes out to the file.
I am able to do it for plain text, and colored text, and pictures/images,
and lines and rectangles.
But for ROTATED text (text which is NOT horizontal, but lies at an angle on the page), I am bumping into a brick wall.
I have been able to "sort of" solve this by creating a temporary picture object with the rotated text in it, then writing that picture out to the RTF.
This works, but it is somewhat clumsy... and my determination of the picture dimensions, based on the angle of text rotation is really clumsy.
So I am looking for an alternative.
I am looking at the code details of an RTF file which has rotated text in it.
It uses a "shape", and then inserts a long string of hex data after all the appropriate codes. And this does it just fine.
So, to my question,
do you have any further info on the format/content of the hex string which I might be able to use to employ this solution, rather than my picture box ?
I enclose a direct copy/paste of the rtf file which contains the "shape" code and which seems to work.
Code:
{\shp{\*\shpinst\shpleft0\shptop0\shpright32000\shpbottom32000
\shpfhdr0\shpbxpage\shpbypage\shpwr3\shpwrk0\shpfblwtxt0\shpz0\shplid1025
{\sp{\sn shapeType}{\sv 75}}
{\sp{\sn fFlipH}{\sv 0}}
{\sp{\sn fFlipV}{\sv 0}}
{\sp{\sn pib}{\sv
{\pict\wmetafile8
0100090000038200000002001C00000000000400000003010800050000000B0200000000050000000C02007D007D1C000000FB023DFF00007A0D7A0D90010000000000100000417269616C00A775440F0AA2709F740730CA120010DAA475C060A775610F66A7040000002D010000050000000902FF8000001A000000210527002E205072696E7420707265766965772069732074686520626573742C20616E676C6520333435B00050195019050000000902010000001C000000FB021000070000000000BC02000000000102022253797374656D0000610F66A700000A0022008A0100000000FFFFFFFFBCCA1200040000002D01010004000000F0010000030000000000
}}}
}
}
The hex in red is the actual string displayed....
"Print Preview is the best, angle 345 [code for 'degrees']",
and the color is sort of "orange".
I need to know what all the code leading up to, and following that text is.
I have searched high and low, but just can't seem to find anything.
Can you help me, please.
Thanks
-
Re: RichTextBox Tricks and Tips
Search for Windows Metafile. Afaik the hex presentation is just a regular data of a WMF file.
-
Re: RichTextBox Tricks and Tips
The file MISUIUtilities.ocx is still missing from your two zip files posted in #83 and #88.
-
Re: RichTextBox Tricks and Tips
Is there a way to prevent users from resizing the images when they are inserted into a RTB?
-
Re: RichTextBox Tricks and Tips
I don't get the following code perform correctly:
vb Code:
Private Sub text2ADDText(xText As RichTextBox, fontN As String, fontS As Integer, fontI As Boolean, fontU As Boolean, fontB As Boolean, txt As String)
Dim text2Len As Long
text2Len = Len(xText.Text)
xText.Text = xText.Text & vbCr & vbLf & txt
xText.SelStart = text2Len + 2
xText.SelLength = Len(txt)
xText.SelBold = fontB
xText.SelUnderline = fontU
xText.SelFontName = fontN
xText.SelFontSize = fontS
End Sub
It only produces the desired result in the last line added to the control invoking the sub.
Could you help me ...
El quijoteMx
-
Re: RichTextBox Tricks and Tips
Quote:
Originally Posted by quijotemx
I don't get the following code perform correctly:
Is this any better?
Code:
Private Sub AppendText(RTB As RichTextBox, _
fontN As String, _
fontS As Integer, _
fontI As Boolean, _
fontU As Boolean, _
fontB As Boolean, _
NewText As String, _
Optional TextColor As Long = vbBlack)
With RTB
.SelStart = Len(.Text)
.SelColor = TextColor
.SelBold = fontB
.SelItalic = fontI
.SelUnderline = fontU
.SelFontName = fontN
.SelFontSize = fontS
.SelText = vbCrLf & NewText
End With
End Sub
-
Re: Insert Tables
moeur:
I downloaded your program to make tables in RichTextBox.
I am using It in a program I'm developing; when I run my program It writes the new table, but It repeats the table that was in the RichTextBox. How do I delete the first table and show only the new table?
This is:
1 UNO 2 12 5 5
3 TRES 2 7 4 5
5 CINCO 2 12 5 5
6 SEIS 2 12 5 5
7 SIETE 2 12 5 5
25 25 2 12 5 5
40 40 2 4 4 5
41 41 2 12 5 5
42 42 2 12 5 5
43 43 2 12 5 5
44 CUATROCUAT 2 10 4 5
45 CUATROCINC 2 12 5 5
46 CUATROSEIS 2 4 4 5
47 CUATROSIET 2 12 5 5
48 CUATROOCHO 2 12 5 5
49 CUATRONUEV 2 7 4 5
50 CINCUENTA 2 8 4 5
51 CINCOUNO 2 11 5 5
52 CINCODOS 2 10 4 5
60 60 2 12 5 5
61 61 2 5 5 5
1 UNO 2 12 5 5
3 TRES 2 7 4 5
5 CINCO 2 12 5 5
6 SEIS 2 12 5 5
7 SIETE 2 12 5 5
40 40 2 4 4 5
41 41 2 12 5 5
42 42 2 12 5 5
43 43 2 12 5 5
44 CUATROCUAT 2 10 4 5
45 CUATROCINC 2 12 5 5
46 CUATROSEIS 2 4 4 5
47 CUATROSIET 2 12 5 5
48 CUATROOCHO 2 12 5 5
49 CUATRONUEV 2 7 4 5
50 CINCUENTA 2 8 4 5
51 CINCOUNO 2 11 5 5
52 CINCODOS 2 10 4 5
60 60 2 12 5 5
61 61 2 5 5 5
Thanks You.
fsossaco
{Email removed}
-
Re: RichTextBox Tricks and Tips
Does Anybody Know How To Make Bold Writing In A Rich Textbox?
I Have Tried Lots Of Ways But Just Cannot Seem To Find One.
Cheers Daniel
-
Re: RichTextBox Tricks and Tips
Welcome to VBForums :wave:
I'm afraid you are in the wrong forum - this one is for VB6 and earlier, and according to your profile you are using VB2008, which is VB.Net
You may be able to find a thread like this in our CodeBank - Visual Basic .NET forum which contains the answer. If not, try asking in our VB.Net forum.
-
Re: RichTextBox Tricks and Tips
Thanks for the great RTB tips.
I'm trying to get the spell check to work, all is OK except for right-click to display menu of suggestions. I think this is because all my RTBs are within various pages of SSTab controls on my forms, so the RTB's parent is not the form itself.
I tried some basic changes to clsSpellCheck, such as hard-coding frmxxxx.hwnd rather than mRTB.Parent.hwnd, but with no success.
Am I wasting my time trying to do this with RTBs contained within SSTabs rather than directly within the form?
-
Re: Auto Detect and respond to URLs
The code is really neat and it works.
Unfortunately it disables the RTB's Change and SelChange events, and I need at least the Change Event to enable the Save button in my Toolbar and to ask for to save changes on exit.
Any solutions?
-
Re: RichTextBox Tricks and Tips
KeyPress and tracking text length between saves/status checks should work for you. The only case it won't work is when someone pastes and cuts texts of exact length by using mouse only. I'd say that is pretty rare. If you use a custom context menu or disable it then this too becomes a non-issue.