CString strText; int nLineCount = m_edit.GetLineCount(); for (int i = 0; i < nLineCount; i++) { int len = m_edit.LineLength(m_edit.LineIndex(i)); m_edit.GetLine(i, strText.GetBuffer(len), len); strText.ReleaseBuffer(len); }