Click to See Complete Forum and Search --> : RTF
urs
August 20th, 2001, 09:11 AM
hi
i am using 2 rtf boxes
when the user input some text and click on a button it gets added to the first text box in a new line along with the text which was already present
if the user uses a different font name first
and then he changes to another one the whole text in the first text box get changed
i only need the text which has been added afterwards to have different font
plzz help me
Ghost308
August 20th, 2001, 09:21 AM
What code are you using to append the text to the RTF box? Have you tried using the SelText property?
'after changing the font, try something like this
RTF1.SelText = RTF1.SelText & Chr(13) & Chr(10) & strNewLine
I hope this is a step in the right direction for you, post your code if you can and maybe we can tell more.
urs
August 20th, 2001, 09:33 AM
Private Sub Command4_Click()
Dim l1 As Long
l1 = Len(Text1.Text) + 2
Text1.Text = Text1.Text + vbNewLine + Text2.Text
Text2.Text = ""
Text1.SetFocus
Text1.SelStart = l1
Text1.SelLength = Len(Text1.Text)
Text1.SelFontName = lstFont.Text
Text1.SelFontSize = lstSize.Text
Text2.SetFocus
End Sub
well this is my coding
text1 is the first rtf
and text2 is the second rtf
and lstFont is the list of the font name
and lstSize is list of the font size
urs
August 20th, 2001, 10:03 AM
hi this code is not working the first time
but it does work the next time
how to make it work the first time
this is where i have added ur line
Dim l1 As Long
l1 = Len(Text1.Text) + 2
Text1.SelText = text1.SelText &Chr(13) & Chr(10) & Text2.Text
Text2.Text = ""
Text1.SetFocus
Text1.SelFontName = lstFont.Text
Text1.SelFontSize = lstSize.Text
Text2.SetFocus
Ghost308
August 20th, 2001, 10:18 AM
Hmm, Try this...
text1.SelStart = len(text1.Text)
text1.SelText = text1.SelText & vbCrLf & text2.Text
text2.Text = ""
text1.SetFocus
text1.SelFontName = lstFont.Text
text1.SelFontSize = lstSize.Text
text2.SetFocus
Since I am using the line "text1.SelStart = Len(text1.Text)" at the beginning, you should be able to take out the lines that monitor the selection position. Let me know how it runs!
Jeff
urs
August 20th, 2001, 10:27 AM
yup this now working at its best
i have made just on change and its working
thanx a lot
i really need that
but i have one more problem
now i have a list box color
and i am trying
"text1.selcolor = lst.text"
it is giving me error plzz let me know what is the error
thanx one again
John G Duffy
August 20th, 2001, 10:27 AM
I have found out that trying to append text to a richtextbox using concatenation does not work very well. some deficiencies in the RTB control itself. Here is an example using SendKeys to append text to a RTB changing the Fontname and font size. I am not a fan of SendKeys but is solved a lot of text manipulation problems I had when I was developing a APP using RichTextBoxes, Problems just like you describe.
private Sub Command1_Click()
' append new text at a different font and size
RTB.SelStart = len(RTB.Text)
RTB.SelFontName = "Courier"
RTB.SelFontSize = 18
RTB.SetFocus ' Important
SendKeys vbCrLf & Text1.Text, true
End Sub
John G
Ghost308
August 20th, 2001, 10:31 AM
Let me make sure I understand... are you using a Listbox populated with names of colors to allow the user to choose what color his/her font will be in text1?
urs
August 20th, 2001, 10:32 AM
thanx for ur adivce but i got it
check out his last post its is working well
thanx
again
hope to get ur help again
urs
August 20th, 2001, 10:36 AM
yup i am using color name
like Blue,Green,Red,Black
and if u can suggest me some more color name plzz
Ghost308
August 20th, 2001, 10:50 AM
When setting colors, VB doesn't use just the color name itself, instead it uses the value of the color. For instance, Blue = &H00FF0000&
The way I usually get the color values I'm wanting is like this... (if anyone knows a better/quicker way, please jump in! :)
I use the properties window in the VB IDE by clicking on any object, let's say a form, then scrolling to its BackColor property. In that property window, you see the color itselfl, along with its value. If you want another color value to copy and paste into your code, just select another color and grab its value. You can set these values as constants in your code like this...
Const Blue = &H00FF0000&
I don't think I have a list of color constants to define... I have checked the API viewer for them but didn't see them right off.
If you are going to use the listbox to display a list of optional colors, I would put a Select Case statement in its LostFocus event so that when the user goes back to type, it selects what color value to use based on what item is selected, then set that color value to the text1.
Select Case List1.Text
Case "Blue":
MyColor = &H00FF0000&
'case "blah":
'MyColor = value of blah
End Select
text1.selcolor = MyColor
urs
August 20th, 2001, 10:58 AM
thanx i was also thinking the same
Ghost308
August 22nd, 2001, 09:45 AM
Hi there,
I was just thumbing through some info on color effects in vb and discovered that color constants are programmed into vb... can't believe i've never had cause to notice these before... here is the table i found, i hope this helps out some!
vbBlack &H000000
vbBlue &HFF0000
vbCyan &HFFFF00
vbGreen &H00FF00
vbMagenta &HFF00FF
vbRed &H0000FF
vbWhite &HFFFFFF
vbYellow &H00FFFF
urs
August 23rd, 2001, 02:11 AM
hi thanx for u information
but u know what
if u declare a variable as colorconstant
then u dont need to know that constants
it will automatically show them
thanx once again
one more thing
i know the color constants like the one u use
can i convert them and get them in RGB i hope u understood
plzz help me
John G Duffy
August 23rd, 2001, 07:56 AM
public Enum Qcolor
black = &H0& ' QBColor 0
Navy = &H800000 ' QBColor 1
blue = &HFF0000
green = &HFF00& ' QBColor 2
Teal = &H808000 ' QBColor 3
Cyan = Teal
maroon = &H80& ' QBColor 4
red = maroon
Purple = &H800080 ' QBColor 5
Magenta = &HFF00FF
Olive = &H8080& ' QBColor 6
Yellow = Olive
Silver = &HC0C0C0 ' QBColor 7
white = Silver
Gray = &H808080 ' QBColor 8
LtBlue = &HFF0000 ' QBColor 9
Lime = &HFF00& ' QBColor 10
LtGreen = Lime
Aqua = &HFFFF00 ' QBColor 11
LtCyan = Aqua
LtRed = &HFF& ' QBColor 12
FUSCHIA = &HFF00FF ' QBColor 13
LtMagenta = FUSCHIA
LtYellow = &HFFFF& ' QBColor 14
BrightWHITE = &HFFFFFF ' QBColor 15
End Enum
John G
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.