Partager via


CEdit::SetReadOnly

Calls this function to set the read-only state of an edit control.

BOOL SetReadOnly( 
   BOOL bReadOnly = TRUE  
);

Parameters

  • bReadOnly
    Specifies whether to set or remove the read-only state of the edit control. A value of TRUE sets the state to read-only; a value of FALSE sets the state to read/write.

Return Value

Nonzero if the operation is successful, or 0 if an error occurs.

Remarks

The current setting can be found by testing the ES_READONLY flag in the return value of CWnd::GetStyle.

For more information, see EM_SETREADONLY in the Windows SDK.

Example

// Set the edit control to be read-only.
m_myEdit.SetReadOnly(TRUE);
ASSERT(m_myEdit.GetStyle() & ES_READONLY);

Requirements

Header: afxwin.h

See Also

Reference

CEdit Class

Hierarchy Chart

CWnd::GetStyle