SelHangingIndent, SelIndent, SelRightIndent Properties

Purpose

Returns or sets the margin settings for the paragraph(s) in a RichEdit control that either contain the current selection or are added at the current insertion point.

Syntax

object.SelHangingIndent [= variant]

object.SelIndent [=variant]

object.SelRightIndent [= variant]

object:RichEdit

Description

These properties return and set a Variant (Long) that determines the amount of indent. These properties use the Twips scale mode units.

These properties return Null if the selection spans multiple paragraphs with different margin settings.

Example

OpenW 1 : AutoRedraw = 1

Global Int32 n, rdpos

Ocx RichEdit red = "", 10, 10, 200, 200 : .MultiLine = True : .BorderStyle = 1

Ocx TextBox tb(1) = "", 230, 10, 60, 14 : tb(1).ReadOnly = True : tb(1).BorderStyle = : Text 297, 11, "Hanging Indent"

Ocx UpDown up(1) : With up(1) : .BuddyControl = tb(1) : .Increment = 50 : .Min = -1000 : .Max = 1000 : .Value = red.SelHangingIndent : End With

Ocx TextBox tb(2) = "", 230, 30, 60, 14 : tb(2).ReadOnly = True : tb(2).BorderStyle = : Text 297, 31, "Left Indent"

Ocx UpDown up(2) : With up(2) : .BuddyControl = tb(2) : .Increment = 50 : .Min = 0 : .Max = 1000 : .Value = red.SelIndent : End With

Ocx TextBox tb(3) = "", 230, 50, 60, 14 : tb(3).ReadOnly = True : tb(3).BorderStyle = : Text 297, 51, "Right Indent"

Ocx UpDown up(3) : With up(3) : .BuddyControl = tb(3) : .Increment = 50 : .Min = 0 : .Max = 1000 : .Value = red.SelRightIndent : End With

For n = 1 To 40 : red.Text = red.Text & "GFA BASIC is great " : Next n

Do : Sleep : Until Me Is Nothing

 

Sub red_GotFocus

red.SelStart = rdpos

EndSub

 

Sub red_LostFocus

If Not red Is Nothing Then rdpos = red.SelStart

EndSub

 

Sub up_Change(Index%)

Select Index%

Case 1 : red.SelHangingIndent = up(1).Value

Case 2 : red.SelIndent = up(2).Value

Case 3 : red.SelRightIndent = up(3).Value

EndSelect

red.SetFocus

EndSub

To find if the current selection contains some (but not all) indented text, use the following code:

If IsNull(RichEdit1.SelIndent) = True Then

' Code to run when selection is mixed.

Else      ' RichEdit1.SelIndent > 0

' Code to run when selection is not mixed.

End If

Known Issues

[Fixed OCX v2.36 Build 1905] When you update either SelHangingIndent or SelIndent, the other assumes the same value. Additionally, the value in either only seems to create a standard left indent - it is not possible to get a hanging indent. There is currently no workaround for this problem.

See Also

RichEdit

{Created by Sjouke Hamstra; Last updated: 20/05/2019 by James Gaite}