[blue]Option Explicit
Private Const MAX_TAB_STOPS = 32&
Private Const EM_SETPARAFORMAT = &H447
Private Const PFM_LINESPACING = &H100&
Private Type PARAFORMAT2
cbSize As Integer
wPad1 As Integer
dwMask As Long
wNumbering As Integer
wReserved As Integer
dxStartIndent As Long
dxRightIndent As Long
dxOffset As Long
wAlignment As Integer
cTabCount As Integer
lTabStops(0 To MAX_TAB_STOPS - 1) As Long
dySpaceBefore As Long ' Vertical spacing before para
dySpaceAfter As Long ' Vertical spacing after para
dyLineSpacing As Long ' Line spacing depending on Rule
sStyle As Integer ' Style handle
bLineSpacingRule As Byte ' Rule for line spacing
bCRC As Byte ' Reserved for CRC for rapid searching
wShadingWeight As Integer ' Shading in hundredths of a per cent
wShadingStyle As Integer ' Nibble 0: style, 1: cfpat, 2: cbpat
wNumberingStart As Integer ' Starting value for numbering
wNumberingStyle As Integer ' Alignment, roman/arabic, (), ), ., etc.
wNumberingTab As Integer ' Space between 1st indent and 1st-line text
wBorderSpace As Integer ' Space between border and text(twips)
wBorderWidth As Integer ' Border pen width (twips)
wBorders As Integer ' Byte 0: bits specify which borders; Nibble 2: border style; 3: color index*/
End Type
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Function SelLineSpacing(rtbTarget As RichTextBox, SpacingRule As Long, Optional LineSpacing As Long = 20)
[green] ' SpacingRule
' Type of line spacing. To use this member, set the PFM_SPACEAFTER flag in the dwMask member. This member can be one of the following values.
' 0 - Single spacing. The dyLineSpacing member is ignored.
' 1 - One-and-a-half spacing. The dyLineSpacing member is ignored.
' 2 - Double spacing. The dyLineSpacing member is ignored.
' 3 - The dyLineSpacing member specifies the spacingfrom one line to the next, in twips. However, if dyLineSpacing specifies a value that is less than single spacing, the control displays single-spaced text.
' 4 - The dyLineSpacing member specifies the spacing from one line to the next, in twips. The control uses the exact spacing specified, even if dyLineSpacing specifies a value that is less than single spacing.
' 5 - The value of dyLineSpacing / 20 is the spacing, in lines, from one line to the next. Thus, setting dyLineSpacing to 20 produces single-spaced text, 40 is double spaced, 60 is triple spaced, and so on.[/green]
Dim Para As PARAFORMAT2
With Para
.cbSize = Len(Para)
.dwMask = PFM_LINESPACING
.bLineSpacingRule = SpacingRule
.dyLineSpacing = LineSpacing
End With
SendMessage rtbTarget.hwnd, EM_SETPARAFORMAT, ByVal 0&, Para
End Function[/blue]