Hi JJ
yes, this is what i did, but when exporting, the background color are not being displayed.
I made a small function to control fonts and colors under a simple structure that the user control. It displays properly on the richedit control the background color, but when trying to export the background is gone.
The main functions is something like this:
;;
SetRTFFont
This function controls all effects of a given font inside a richedit control
Arguments
hRTF: Handle to the RichEdit Control
RTF_Sruct: A pointer to a RTF_SETUP structure to configurate the used font and color.
;;
Proc SetRTFFont:
Arguments @hRTF, @RTF_Struct
Structure @ChrFmt 84, @ChrFmt_cbSizeDis 0, @ChrFmt_dwMaskDis 4, @ChrFmt_dwEffectsDis 8, @ChrFmt_yHeightDis 12, @ChrFmt_yOffsetDis 16, @ChrFmt_crTextColorDis 20,
@ChrFmt_bCharSetDis 24, @ChrFmt_bPitchAndFamilyDis 25, @ChrFmt_szFaceNameDis 26, @ChrFmt__wPad2Dis 58, @ChrFmt_wWeightDis 60,
@ChrFmt_sSpacingDis 62, @ChrFmt_crBackColorDis 64, @ChrFmt_lcidDis 68, @ChrFmt_dwReservedDis 72, @ChrFmt_sStyleDis 76,
@ChrFmt_wKerningDis 78, @ChrFmt_bUnderlineTypeDis 80, @ChrFmt_bAnimationDis 81, @ChrFmt_bRevAuthorDis 82, @ChrFmt_bReserved1Dis 83
Uses esi, edi, ebx, ecx, eax, edx
mov esi D@RTF_Struct
call 'GDI32.GetStockObject' &DEFAULT_GUI_FONT
call 'USER32.SendMessageA' D@hRTF &WM_SETFONT, eax, &FALSE
call 'USER32.SendMessageA' D@hRTF, &EM_SETBKGNDCOLOR, 0, D$esi+RTF_SETUP.ControlBackColorDis <----- This works, but does not exports if i create a RTF file:(:(:(
call 'GDI32.CreateFontA' D$esi+RTF_SETUP.nHeightDis, D$esi+RTF_SETUP.nWidthDis, D$esi+RTF_SETUP.nEscapementDis, D$esi+RTF_SETUP.nOrientationDis, D$esi+RTF_SETUP.fnWeightDis,
D$esi+RTF_SETUP.fdwItalicDis, D$esi+RTF_SETUP.fdwUnderlineDis, D$esi+RTF_SETUP.fdwStrikeOutDis, D$esi+RTF_SETUP.fdwCharSetDis,
D$esi+RTF_SETUP.fdwOutputPrecisionDis, D$esi+RTF_SETUP.fdwClipPrecisionDis, D$esi+RTF_SETUP.fdwQualityDis, D$esi+RTF_SETUP.fdwPitchAndFamilyDis,
D$esi+RTF_SETUP.lpszFaceDis
mov ebx eax ; our font handle
call 'USER32.SendMessageA' D@hRTF, &WM_SETFONT, eax, &TRUE
call ZeroMemory D@ChrFmt, 84
mov D@ChrFmt_cbSizeDis 84
mov D@ChrFmt_dwMaskDis &CFM_COLOR
move D@ChrFmt_crTextColorDis D$esi+RTF_SETUP.FontColorDis
call 'USER32.SendMessageA' D@hRTF, &EM_SETCHARFORMAT, &SCF_ALL, D@ChrFmt
;call 'USER32.SendMessageA' D@hRTF, &EM_GETEDITSTYLE, 0, 0
;call 'USER32.SendMessageA' D@hRTF, &EM_SETEDITSTYLE, &SES_EXTENDBACKCOLOR, &SES_EXTENDBACKCOLOR ; &EM_SCROLLCARET
; SES_EXTENDBACKCOLOR
call ZeroMemory D@ChrFmt, 84
mov D@ChrFmt_cbSizeDis 84
mov D@ChrFmt_dwMaskDis &CFM_BACKCOLOR
move D@ChrFmt_crBackColorDis D$esi+RTF_SETUP.ControlBackColorDis
call 'USER32.SendMessageA' D@hRTF, &EM_SETCHARFORMAT, &SCF_ALL, D@ChrFmt
; delete our new font.
call 'gdi32.DeleteObject' ebx
EndP
RTF_SETUP structure
[RTF_SETUP:
RTF_SETUP.FontColor: D$ (160 or (22 shl 8) or (24 shl 16)) <-----The font color
RTF_SETUP.ControlBackColor: D$ (224 or (221 shl 8) or (198 shl 16)) <----- The color of the background of the font
RTF_SETUP.nHeight: D$ 16 <--- This parameter and the others are exactly the same one as in CreateFont Api.
RTF_SETUP.nWidth: D$ 0
RTF_SETUP.nEscapement: D$ 0
RTF_SETUP.nOrientation: D$ 0
RTF_SETUP.fnWeight: D$ &FW_DONTCARE
RTF_SETUP.fdwItalic: D$ &FALSE
RTF_SETUP.fdwUnderline: D$ &FALSE
RTF_SETUP.fdwStrikeOut: D$ &FALSE
RTF_SETUP.fdwCharSet: D$ &DEFAULT_CHARSET
RTF_SETUP.fdwOutputPrecision: D$ &OUT_DEFAULT_PRECIS
RTF_SETUP.fdwClipPrecision: D$ &CLIP_DEFAULT_PRECIS
RTF_SETUP.fdwQuality: D$ &DEFAULT_QUALITY
RTF_SETUP.fdwPitchAndFamily: D$ &DEFAULT_PITCH
RTF_SETUP.lpszFace: D$ Sz_RTFFontName]
[Sz_RTFFontName: B$ "MS Sans Serif", 0]
Example of usage:
[RTF_SETUP:
RTF_SETUP.FontColor: D$ (160 or (22 shl 8) or (24 shl 16))
RTF_SETUP.ControlBackColor: D$ (224 or (221 shl 8) or (198 shl 16))
RTF_SETUP.nHeight: D$ 16
RTF_SETUP.nWidth: D$ 0
RTF_SETUP.nEscapement: D$ 0
RTF_SETUP.nOrientation: D$ 0
RTF_SETUP.fnWeight: D$ &FW_DONTCARE
RTF_SETUP.fdwItalic: D$ &FALSE
RTF_SETUP.fdwUnderline: D$ &FALSE
RTF_SETUP.fdwStrikeOut: D$ &FALSE
RTF_SETUP.fdwCharSet: D$ &DEFAULT_CHARSET
RTF_SETUP.fdwOutputPrecision: D$ &OUT_DEFAULT_PRECIS
RTF_SETUP.fdwClipPrecision: D$ &CLIP_DEFAULT_PRECIS
RTF_SETUP.fdwQuality: D$ &DEFAULT_QUALITY
RTF_SETUP.fdwPitchAndFamily: D$ &DEFAULT_PITCH
RTF_SETUP.lpszFace: D$ Sz_RTFFontName]
[Sz_RTFFontName: B$ "MS Sans Serif", 0]
call SetRTFFont D$hMyRTF, RTF_SETUP