Export (0) Print
Expand All
Expand Minimize
0 out of 1 rated this helpful - Rate this topic


Retrieves the number of lines in the CRichEditCtrl object.

int GetLineCount( ) const;

The number of lines in this CRichEditCtrl object.

For more information, see EM_GETLINECOUNT in the Windows SDK.

int nLineLength, nLineIndex, nLineCount = m_myRichEditCtrl.GetLineCount();
CString strText, strLine;

// Dump every line of text of the rich edit control. 
for (int i = 0; i < nLineCount; i++)
   nLineIndex = m_myRichEditCtrl.LineIndex(i);
   nLineLength = m_myRichEditCtrl.LineLength(nLineIndex);
   m_myRichEditCtrl.GetLine(i, strText.GetBufferSetLength(nLineLength + 1),
   strText.SetAt(nLineLength, _T('\0')); // null terminate
   strText.ReleaseBuffer(nLineLength + 1);

   TRACE(_T("line %d: '%s'\r\n"), i, strText);

Header: afxcmn.h

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft. All rights reserved.