$INCLUDE "Rapidq.inc"
DECLARE FUNCTION SendMessageA LIB "user32" ALIAS "SendMessageA"_
(BYVAL hwnd AS LONG,BYVAL wMsg AS LONG,BYVAL wParam AS LONG,lParam AS LONG) AS LONG
CONST WM_USER = &H400
CONST CFM_BACKCOLOR = &H4000000
CONST EM_SETCHARFORMAT = WM_USER + 68
CONST EM_FORMATRANGE = WM_USER + 57
CONST SCF_SELECTION = &H0001
CONST EM_SETBKGNDCOLOR =WM_USER + 67
CONST SCF_ALL = 4
CONST CFM_BOLD = &H00000001
CONST CFM_ITALIC = &H00000002
CONST CFM_UNDERLINE = &H00000004
CONST CFM_STRIKEOUT = &H00000008
CONST CFM_PROTECTED = &H00000010
CONST CFM_SIZE = &H80000000
CONST CFM_COLOR = &H40000000
CONST CFM_FACE = &H20000000
CONST CFM_OFFSET = &H10000000
CONST CFM_CHARSET = &H08000000
CONST CFE_BOLD = &H0001
CONST CFE_ITALIC = &H0002
CONST CFE_UNDERLINE = &H0004
CONST CFE_STRIKEOUT = &H0008
CONST CFE_PROTECTED = &H0010
CONST CFE_AUTOCOLOR = &H40000000
CONST LF_FACESIZE =32
TYPE CHARFORMAT1
cbSize AS SHORT
wPad1 AS SHORT
dwMask AS DWORD
dwEffects AS DWORD
yHeight AS DWORD
yOffset AS DWORD
crTextColor AS LONG
bCharSet AS BYTE
bPitchAndFamily AS BYTE
szFaceName AS STRING*32
wPad2 AS SHORT
END TYPE
TYPE CHARFORMAT2
cbSize AS SHORT
wPad1 AS SHORT
dwMask AS LONG
dwEffects AS LONG
yHeight AS LONG
yOffset AS LONG
crTextColor AS LONG
bCharSet AS BYTE
bPitchAndFamily AS BYTE
szFaceName AS STRING*32
wPad2 AS SHORT
wWeight AS SHORT
sSpacing AS SHORT
crBackColor AS LONG
lLCID AS LONG
dwReserved AS LONG
sStyle AS SHORT
wKerning AS SHORT
bUnderlineType AS BYTE
bAnimation AS BYTE
bRevAuthor AS BYTE
bReserved1 AS BYTE
END TYPE
DECLARE SUB Highlight (Sender AS QBUTTON)
CREATE Form AS QFORM
Width = 750
Height = 531
Center
CREATE Panel1 AS QPANEL
Height = 57
Align = 1
CREATE Button1 AS QBUTTON
CAPTION = "Highlight Text"
Left = 8
Top = 8
Width = 171
OnClick = Highlight
END CREATE
END CREATE
CREATE Panel2 AS QPANEL
Align = 5
TabOrder = 1
CREATE RichEdit AS QRICHEDIT
Align = 5
HideSelection = 0
ScrollBars = 3
WantTabs = 1
AddStrings "This is a test. This is a Test. -------------------------------"
SelStart = 0
SelLength = 15
END CREATE
END CREATE
END CREATE
Form.SHOWMODAL
SUB Highlight (Sender AS QBUTTON)
DIM M AS QMEMORYSTREAM
DIM CharFormat AS CHARFORMAT2
CharFormat.dwMask = CFM_BACKCOLOR
CharFormat.crBackColor =clYellow
PRINT SIZEOF(CharFormat)
CharFormat.cbSize =SIZEOF(CharFormat)
M.Position=0
M.WriteUDT(CHARFORMAT)
z=SendMessageA(RichEdit.Handle, EM_SETCHARFORMAT, SCF_SELECTION, M.Pointer)
PRINT "SendMessageA return=",z
END SUB
|