
How to send the API SendMessage with the CHARFORMAT2 structure - wave undereline like word
How would you do this in
C# ( from VB code I wrote to make the wave
underline like word):
Private Type CHARFORMAT2
cbSize As Integer
wPad1 As Integer
dwMask As Long
dwEffects As Long
yHeight As Long
yOffset As Long
crTextColor As Long
bCharSet As Byte
bPitchAndFamily As Byte
szFaceName(0 To LF_FACESIZE - 1) As Byte
wPad2 As Integer
' Additional stuff supported by RICHEDIT20
wWeight As Integer ' /* Font weight (LOGFONT value) */
sSpacing As Integer ' /* Amount to space between letters */
crBackColor As Long ' /* Background color */
lLCID As Long ' /* Locale ID */
dwReserved As Long ' /* Reserved. Must be 0 */
sStyle As Integer ' /* Style handle */
wKerning As Integer ' /* Twip size above which to kern char
pair*/
bUnderlineType As Byte ' /* Underline type */
bAnimation As Byte ' /* Animated text like marching ants */
bRevAuthor As Byte ' /* Revision author index */
bReserved1 As Byte
End Type
Const WM_USER = &H400
Const EM_SETCHARFORMAT = (WM_USER + 68)
Const CFM_UNDERLINETYPE = &H800000
Const CFE_UNDERLINE = &H4&
Const CFM_UNDERLINE = &H4
Private Sub Command1_Click()
Dim CF2 As CHARFORMAT2
With CF2
.cbSize = LenB(CF2)
.dwMask = CFM_UNDERLINETYPE
.dwEffects = CFM_UNDERLINE
.bUnderlineType = 88
End With
SendMessage rtfbox.hWnd, EM_SETCHARFORMAT, CFE_UNDERLINE, CF2
end sub
Changing the bUnderline to from 81 to 89 provides different underline styles
in red, Experiment with values between 19 to 89 and see the effects.
Patrick Blackman