CRichEditCtrl::SetSelectionCharFormat
Sets the character formatting attributes for the text in the current selection in this CRichEditCtrl object.
BOOL SetSelectionCharFormat(
CHARFORMAT& cf
);
BOOL SetSelectionCharFormat(
CHARFORMAT2& cf
);
Parameters
cf
In the first version, a pointer to a CHARFORMAT structure containing the new character formatting attributes for the current selection.In the second version, a pointer to a CHARFORMAT2 structure, which is a Rich Edit 2.0 extension to the CHARFORMAT structure, containing the new character formatting attributes for the current selection.
Return Value
Nonzero if successful; otherwise, 0.
Remarks
Only the attributes specified by the dwMask member of cf are changed by this function.
For more information, see the EM_SETCHARFORMAT and the CHARFORMAT and CHARFORMAT2 structures in the Windows SDK.
Example
CHARFORMAT cf;
// Modify the selection format so that the selected text is
// displayed in bold and not striked out.
cf.cbSize = sizeof(cf);
cf.dwMask = CFM_STRIKEOUT|CFM_BOLD;
cf.dwEffects = CFE_BOLD;
m_myRichEditCtrl.SetSelectionCharFormat(cf);
// Verify the settings are what is expected.
m_myRichEditCtrl.GetSelectionCharFormat(cf);
ASSERT((cf.dwMask&(CFM_STRIKEOUT|CFM_BOLD)) ==
(CFM_STRIKEOUT|CFM_BOLD));
ASSERT((cf.dwEffects&(CFE_STRIKEOUT|CFE_BOLD)) == CFE_BOLD);
Requirements
Header: afxcmn.h
See Also
Reference
CRichEditCtrl::GetSelectionCharFormat
CRichEditCtrl::SetDefaultCharFormat