Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

CRichEditView::GetCharFormatSelection

Call this function to get the character formatting attributes of the current selection.

CHARFORMAT2& GetCharFormatSelection( );

A CHARFORMAT2 structure which contains the character formatting attributes of the current selection.

For more information, see the EM_GETCHARFORMAT message and the CHARFORMAT2 structure in the Windows SDK.

void CMyRichEditView::OnCharUnderline ()
{
    CHARFORMAT2 cf;
    cf = GetCharFormatSelection();

    if (!(cf.dwMask & CFM_UNDERLINE) || !(cf.dwEffects & CFE_UNDERLINE))
        cf.dwEffects = CFE_UNDERLINE;
    else
        cf.dwEffects = 0;

    cf.dwMask = CFM_UNDERLINE;
    SetCharFormat(cf);
}

Header: afxrich.h

Community Additions

ADD
Show:
© 2015 Microsoft