CharFormat, DefCharFormat, ParaFormat Property

Purpose

Return or set formatting for a RichEdit control.

Syntax

object.CharFormat [ = format$ ]

object.DefCharFormat [ = format$ ]

object.ParaFormat [ = format$ ]

object:RichEdit

Description

The format$ value for CharFormat and DefCharFormat contains the setting for the character formatting. Each attribute is identified with a character and when necessary followed by a value.

The DefCharFormat property is used to set and retrieve the default character formatting, which is the formatting applied to any subsequently inserted characters. For example, if an application sets the default character formatting to bold and the user then types a character, that character is bold. Initially, DefCharFormat returns:

"biuspC0Y165O0T0F0'MS Sans Serif"

A capital enables the attribute, a lowercase character disables it. The following settings can be used:

"B/b" - Bold; "I/i" - Italic; "U/u" - UnderLine; "S/s" - Strikeout; "P/p" - Protected; "C" & Dec$(RGB()) - Color; "Y" & Dec(t) - Character height in twips; "O" & Dec(t) - Character offset, in twips, from the baseline; "T" - CharSet; "F" - PitchAndFamily; "'"&fontname - Font face name.

format$ = ParaFormat returns the current paragraph formatting for the selected text. This property is used to specify paragraph formatting attributes. The default value is "A0N0O0+0R0S0", meaning.

"A" - Alignment; N - Numbering; "O" - Offset; "+" - relative indenting; "R" - RightIndent; "S" - StartIndent ; "T" - Tabstops. All attributes are followed by a decimal value specifying the attributes setting in twips.

Example

Ocx RichEdit rtf = "", 10, 10, 400, 150 : rtf.BorderStyle = 1 : rtf.SetFocus

Ocx Command cmd(1) = "18pt Text (Italic)", 10, 170, 80, 22

Ocx Command cmd(2) = "36pt Text (Bold)", 100, 170, 80, 22

Do : Sleep : Until Me Is Nothing

 

Sub cmd_Click(Index%)

Local rs = rtf.SelStart

Select Index%

Case 1 : rtf.CharFormat = "bIY360"

Case 2 : rtf.CharFormat = "iBY720"

EndSelect

rtf.SetFocus

rtf.SelStart = rs

EndSub

Remarks

These properties retrieve and set Sel* properties in one step.

See Also

RichEdit

{Created by Sjouke Hamstra; Last updated: 24/09/2014 by James Gaite}