Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

CRichEditCtrl::SetDefaultCharFormat

 

Sets the character formatting attributes for new text in this CRichEditCtrl object.


      BOOL SetDefaultCharFormat(
   CHARFORMAT& cf 
);
BOOL SetDefaultCharFormat(
   CHARFORMAT2& cf 
);

cf

In the first version, a pointer to a CHARFORMAT structure containing the new default character formatting attributes.

In the second version, a pointer to a CHARFORMAT2 structure, which is a Rich Edit 2.0 extension to the CHARFORMAT structure, containing the default character formatting attributes.

Nonzero if successful; otherwise, 0.

Only the attributes specified by the dwMask member of cf are changed by this function.

For more information, see the EM_SETCHARFORMAT message and the CHARFORMAT and CHARFORMAT2 structures in the Windows SDK.

Example

CHARFORMAT cf = {0};

// Modify the default character format so that all new
// text is striked out and not bold.
cf.cbSize = sizeof(cf);
cf.dwMask = CFM_STRIKEOUT|CFM_BOLD;
cf.dwEffects = CFE_STRIKEOUT;
m_myRichEditCtrl.SetDefaultCharFormat(cf);

// Verify the settings are what is expected.
m_myRichEditCtrl.GetDefaultCharFormat(cf);
ASSERT((cf.dwMask&(CFM_STRIKEOUT|CFM_BOLD)) == 
   (CFM_STRIKEOUT|CFM_BOLD));
ASSERT((cf.dwEffects&(CFE_STRIKEOUT|CFE_BOLD)) == CFE_STRIKEOUT);

Requirements

Header: afxcmn.h

Show: