Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

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


else
m_BtnAccount.EnableWindow(TRUE);

// The dialog box can take over now
UpdateData(FALSE);
}

void CExerciseView::OnEnUpdateLastName()
{
// TODO: Add your control notification handler code here
UpdateData();

if( (m_FirstName.GetLength() == 0) || (m_LastName.GetLength() == 0) )
m_BtnAccount.EnableWindow(FALSE);
else
m_BtnAccount.EnableWindow(TRUE);

UpdateData(FALSE);
}


  1. Test the application

  2. Return to MSVC


16.3 The Rich Edit Control.................................................................................


16.3.1..Overview...............................................................................................


A rich edit control is a Windows object that resembles an edit box but can handle text
that is formatted. This mean that it can display text with various characters formats and
can show paragraphs with different alignments. A rich edit control can also allow a user
to change the formatting on characters and control the alignment of paragraphs.

16.3.2..A Rich Edit Control............................................................................


To create a rich edit control, you ca use the Rich Edit button from the Controls toolbox.
You can also programmatically create this control using the CRichEditCtrl class. To do
this, use its (default) constructor:

CRichEditCtrl RichEditor;

After declaring this variable, you can define the characteristics of the control using the
CRichEditCtrl::Create() method. Its syntax is:

BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);

The dwStyle argument specifies the window style to apply to the control. Since the rich
edit control is not a container, it is usually positioned on another control such as a form or
dialog box. Therefore, the primary style you must apply is WS_CHILD. To display the
control to the user, also add the WS_VISIBLE style. This primary style can be defined as
follows:

DWORD RichStyle = WS_CHILD | WS_VISIBLE;
Free download pdf