Freigeben über


CEditView Class

A type of view class that provides the functionality of a Windows edit control and can be used to implement simple text-editor functionality.

class CEditView : public CCtrlView

Members

Public Constructors

Name

Description

CEditView::CEditView

Constructs an object of type CEditView.

Public Methods

Name

Description

CEditView::FindText

Searches for a string within the text.

CEditView::GetBufferLength

Obtains the length of the character buffer.

CEditView::GetEditCtrl

Provides access to the CEdit portion of a CEditView object (the Windows edit control).

CEditView::GetPrinterFont

Retrieves the current printer font.

CEditView::GetSelectedText

Retrieves the current text selection.

CEditView::LockBuffer

Locks the buffer.

CEditView::PrintInsideRect

Renders text inside a given rectangle.

CEditView::SerializeRaw

Serializes a CEditView object to disk as raw text.

CEditView::SetPrinterFont

Sets a new printer font.

CEditView::SetTabStops

Sets tab stops for both screen display and printing.

CEditView::UnlockBuffer

Unlocks the buffer.

Protected Methods

Name

Description

CEditView::OnFindNext

Finds next occurrence of a text string.

CEditView::OnReplaceAll

Replaces all occurrences of a given string with a new string.

CEditView::OnReplaceSel

Replaces current selection.

CEditView::OnTextNotFound

Called when a find operation fails to match any further text.

Public Data Members

Name

Description

CEditView::dwStyleDefault

Default style for objects of type CEditView.

Remarks

The CEditView class provides the following additional functions:

  • Print.

  • Find and replace.

Because class CEditView is a derivative of class CView, objects of class CEditView can be used with documents and document templates.

Each CEditView control's text is kept in its own global memory object. Your application can have any number of CEditView objects.

Create objects of type CEditView if you want an edit window with the added functionality listed above, or if you want simple text-editor functionality. A CEditView object can occupy the entire client area of a window. Derive your own classes from CEditView to add or modify the basic functionality, or to declare classes that can be added to a document template.

The default implementation of class CEditView handles the following commands: ID_EDIT_SELECT_ALL, ID_EDIT_FIND, ID_EDIT_REPLACE, ID_EDIT_REPEAT, and ID_FILE_PRINT.

The default character limit for CEditView is (1024 * 1024 - 1 = 1048575). This can be changed by calling the EM_LIMITTEXT function of the underlying edit control. However, the limits are different depending on the operating system and the type of edit control (single or multiline). For more information on these limits, see EM_LIMITTEXT.

To change this limit in your control, override the OnCreate() function for your CEditView class and insert the following line of code:

GetEditCtrl().SetLimitText(nNewVal); //nNewVal, the new character limit

Objects of type CEditView (or of types derived from CEditView) have the following limitations:

  • CEditView does not implement true what you see is what you get (WYSIWYG) editing. Where there is a choice between readability on the screen and matching printed output, CEditView opts for screen readability.

  • CEditView can display text in only a single font. No special character formatting is supported. See class CRichEditView for greater capabilities.

  • The amount of text a CEditView can contain is limited. The limits are the same as for the CEdit control.

For more information on CEditView, see Derived View Classes Available in MFC.

Inheritance Hierarchy

CObject

CCmdTarget

CWnd

CView

CCtrlView

CEditView

Requirements

Header: afxext.h

See Also

Reference

CCtrlView Class

Hierarchy Chart

CEdit Class

CDocument Class

CDocTemplate Class

CCtrlView Class

CRichEditView Class

Concepts

MFC Sample SUPERPAD