Im trying to find a way to customise tabstop positions in a rich textbox (Miscrosoft Rich Textbox Control 6.0 (SP3)).
According to MS documnetation I should be able to use the 'SendMessage' API function with either the EM_SETTABSTOPS message or the EM_SETPARAFORMAT message.
I can get the EM_SETTABSTOPS message working fine with a normal textbox but get an unsuccessful reponse when using on the rich textbox. The code Im using is as follows where 'rtcEditor' is my rich textbox control:-
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
Const EM_SETTABSTOPS = &HCB
Private Sub TestBtn_Click()
Dim intCount As Integer
Dim tabStops(1 To 16) As Long
Dim boolResult As Boolean
For intCount = 1 To 16
If intCount = 1 Then
tabStops(intCount) = 4 * 4
Else
tabStops(intCount) = tabStops(intCount - 1) + 4 * 4
End If
Next
In the above code, boolResult always returns False and the tabstops are not set.
The other thing Ive tried is to use the EM_SETPARAFORMAT rich textbox specific message as follows:-
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 Type PARAFORMAT2
cbSize As Long
dwMask As Long
wNumbering As Integer
wEffects As Integer
dxStartIndent As Long
dxRightIndent As Long
dxOffset As Long
wAlignment As Integer
cTabCount As Integer
rgxTabs(MAX_TAB_STOPS - 1) As Long
dySpaceBefore As Long
dySpaceAfter As Long
dyLineSpacing As Long
sStyle As Integer
bLineSpacingRule As Byte
bOutlineLevel As Byte
wShadingWeight As Integer
wShadingStyle As Integer
wNumberingStart As Integer
wNumberingStyle As Integer
wNumberingTab As Integer
wBorderSpace As Integer
wBorderWidth As Integer
wBorders As Integer
End Type
For intCount = 0 To MAX_TAB_STOPS - 1
If intCount = 0 Then
udt.rgxTabs(intCount) = 4 * 2
Else
udt.rgxTabs(intCount) = udt.rgxTabs(intCount - 1) + 4 * 2
End If
Next