EM_SETCHARFORMAT message
wParam : SCF_ALL
lParam
Pointer to a CHARFORMAT structure specifying the character formatting to use. Only the formatting attributes specified by the dwMask member are changed.
Type LOGFONTA
lfHeight As Long
lfWidth As Long
lfItalic As Long
lfCharSet As Long
lfFaceName As String
End Type
The character set. The following values are predefined
ANSI_CHARSET=&H0
BALTIC_CHARSET=&BA
CHINESEBIG5_CHARSET
DEFAULT_CHARSET=&H1
EASTEUROPE_CHARSET=&HEE
GB2312_CHARSET=&H86
GREEK_CHARSET=&A1
HANGUL_CHARSET=&H81
MAC_CHARSET=&H4D
OEM_CHARSET=&HFF
RUSSIAN_CHARSET=&HCC
SHIFTJIS_CHARSET=&H80
SYMBOL_CHARSET=&H2
TURKISH_CHARSET=&HA2
VIETNAMESE_CHARSET=&HA3
JOHAB_CHARSET=&H82
ARABIC_CHARSET=&HB2
HEBREW_CHARSET=&HB1
THAI_CHARSET=&HDE
Type CHARFORMATA
cbSize
dwMask : CFM_ALL
dwEffects : CFE_BOLD
yHeight
yOffset
crTextColor
(bCharSet : See LOGFONT Structure (lfCharSet
bPitchAndFamily : See LOGFONT Structure
(lfPitchAndFamily)
szFaceName
End Type
SCF_DEFAULT=&H0
SCF_SELECTION=&H1
SCF_ALL=&H4
'Char Format Effect
CFE_BOLD=&H0
CFE_ITALIC=&H1
CFE_UNDERLINE=&H4
CFE_LINK=&H20
'Char Format Mask
CFM_BOLD=&H0
CFM_ITALIC=&H2
CFM_UNDERLINE=&H4
CFM_COLOR=&H40000000
CFM_CHARSET=&H8000000
Case WM_Command
wm-command
if lparam=hRichEdit Then
SendMessage(hRichEdit,EM_setBkgndColor,False,Green)
Dim P As CharRange
P.cpmin = 0 : P.cpmax = -1
SendMessage(hRichEdit,EM_EXSetSel, 0, VarPtr(p))
'0,-1 selects all 'make selection red Local
Dim cf As CHARFORMAT
cf.cbSize=Len(cf)
cf.dwMask=CFM_COLOR
cf.crTextColor=vbRed
SendMessage(hRichEdit,EM_SETCHARFORMAT,SCF_SELECTION,VarPtr(cf))
P.cpmin = 0:P.cpmax = 0
SendMessage(hRichEdit,EM_EXSetSel,0, VarPtr(p))
End If
Type CHARRANGE
cpMin As Long
cpMax As Long
End Type
CHARRANGE structure
Specifies a range of characters in a rich edit control.
If the cpMin and cpMax members are equal, the range is empty. The range includes everything if cpMin is 0 and cpMax is –1
برای تغییر Font ارسال پیام WM_SETFONT که wparam همان hfont است و lparam هم NonZero
Dim lf As LOGFONT
lf.lfUnderline = 1
lf.lfCharSet = &HB1
(x = CreateFontIndirect(lf
SendMessageA Et, WM_SETFONT, x, 1