Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 16: Text-Based Controls Visual C++ and MFC Fundamentals


Value Description
PFA_LEFT The paragraph will be aligned to the left
PFA_CENTER The paragraph will be aligned to the center
PFA_RIGHT The paragraph will be aligned to the right

The cTabCount and the rgxTabs member variables are used to control tab separation.

To retrieve the paragraph formatting applied on a paragraph, you can call the
CRichEditCtrl::GetParaFormat() method. Its syntax is:

DWORD GetParaFormat(PARAFORMAT& pf) const;

This method returns formatting applied on the selected paragraph.

Practical Learning: Using Rich Edit Properties



  1. Add the following 8 buttons:


ID Caption
IDC_BTN_BOLD B
IDC_BTN_ITALIC I
IDC_BTN_UNDERLINE U
IDC_BTN_STRIKEOUT S
IDC_BTN_LEFT <
IDC_BTN_CENTER =
IDC_BTN_RIGHT >
IDC_BTN_BULLET :


  1. Add a BN_CLICKED event handler for each button and implement the events as
    follows:
    void CRicher1Dlg::OnBnClickedBtnBold()
    {
    // TODO: Add your control notification handler code here
    CHARFORMAT Cfm;


m_Richer.GetSelectionCharFormat(Cfm);

Cfm.cbSize = sizeof(CHARFORMAT);
Cfm.dwMask = CFM_BOLD;
Cfm.dwEffects ^= CFE_BOLD;

m_Richer.SetSelectionCharFormat(Cfm);
m_Richer.SetFocus();
Free download pdf