Hello everyone.
Rather complicated question here. I am improving the text coloring in my custom RTB control, and it is pretty simple:
I have a problem at step 4. I need to set a "header" for the set RTF. I currently use this coding:1. Disable drawing (SetDrawing(False))
2. Get current selection
3. Select lines to colorize
4. Process selection RTF vs selection Text
5. Set old selection
6. Enable drawing (SetDrawing(True))
Produces:Code:Public Sub UpdateColors() Dim tmprtb As New RichTextBox tmprtb.Font = Me.Font tmprtb.Text = "" Me._fontheader = tmprtb.Rtf.Split(vbCrLf)(0) & vbCrLf Me._fontheader &= "{\colortbl ;" Me._fontheader &= "\red" & Me.cf1.R & "\green" & Me.cf1.G & "\blue" & Me.cf1.B & ";" Me._fontheader &= "\red" & Me.cf2.R & "\green" & Me.cf2.G & "\blue" & Me.cf2.B & ";" Me._fontheader &= "\red" & Me.cf3.R & "\green" & Me.cf3.G & "\blue" & Me.cf3.B & ";" Me._fontheader &= "\red" & Me.cf4.R & "\green" & Me.cf4.G & "\blue" & Me.cf4.B & ";" Me._fontheader &= "\red" & Me.cf5.R & "\green" & Me.cf5.G & "\blue" & Me.cf5.B & ";" Me._fontheader &= "\red" & Me.cf6.R & "\green" & Me.cf6.G & "\blue" & Me.cf6.B & ";" Me._fontheader &= "\red" & Me.cf7.R & "\green" & Me.cf7.G & "\blue" & Me.cf7.B & ";}" Dim s As String = tmprtb.Rtf.Split(vbCrLf)(1) Me._fontheader &= vbCrLf & s.Substring(0, s.Length - 4) tmprtb.Dispose() tmprtb = Nothing End Sub
The cf values are text colors used in the document. How can I accomplish the same thing without using a (new) RichTextBox control? Like, parse the information of a Font object.{\rtf1\ansi\ansicpg1252\deff0\deflang1043{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}
{\colortbl ;\red0\green0\blue0;\red0\green128\blue0;\red255\green128\blue0;\red0\green128\blue255;\red0\green0\ blue255;\red255\green0\blue0;\red128\green128\blue128;}
\viewkind4\uc1\pard\f0\fs29




Reply With Quote