Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Colored Richtext Control Fonts

Status
Not open for further replies.

SWilliams15

Programmer
Dec 28, 2000
14
US
I have a rich text control that I would like to print to using different colored fonts. I would like each line to have a different color of font (and other font characterisitics like size if that's possibel). Before the first line is printed to the control, I can use the SelColor command to set the font color. That works and text is printed in the color.

However, then before the second line is printed, i try to SelColor to print the seocnd line in a differnet color, that doesn't work and instead the the second line (and all subsequent lines no matter how many times I change SelColor) are printed with the color of the first line.

How can I get line 1 to print in say green, line 2 to say print in red, line 3 to print in black, line 4 in red again and so on?

Thanks,
Sean
 
Let's see some of the code you're using.
VCA.gif

Alt255@Vorpalcom.Intranets.com
 
Here's the code to set the color. I can set the color for the first line to any of these listed and I've stepped through it to verify that the colors are being set to lColor.

If sCmd = CMD_SETPRINTCOLOR Then
Dim sColor As String
Dim lColor As Long

sColor = GetStringItem(2, gsELCommand(iY), ",")
If sColor = "Green" Then
lColor = vbGreen
ElseIf sColor = "vbBlue" Then
lColor = Blue
ElseIf sColor = "Red" Then
lColor = vbRed
Else
lColor = vbBlack
End If

Form2.RichTextBox1.SelColor = lColor

End If
 
Here's a corrected version of the code above. Still same result.

If sCmd = CMD_SETPRINTCOLOR Then
Dim sColor As String
Dim lColor As Long

sColor = GetStringItem(2, gsELCommand(iY), ",")
If sColor = "Green" Then
lColor = vbGreen
ElseIf sColor = "Blue" Then
lColor = vbBlue
ElseIf sColor = "Red" Then
lColor = vbRed
Else
lColor = vbBlack
End If

Form2.RichTextBox1.SelColor = lColor

End If
 
Im trying to do this too!(August 2002)
Have you found out how to yet?
 

I believe what you need to do is change the fontcolor for each line withing the RTF and then send the whole thing to the printer.

Just a guess
 

sorry hit the button to soon

Just a guess, but then you would need to save the RTF and use the ShellExecute API with the "print" verb and allow MSWord to handle the interpretations of each line of color.

or

printer.ForeColor

and print out the file yourself

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top