我懂了,看了MSDN上的例子:#ifdef _DEBUG extern CEdit* pmyEdit; // The pointer to my edit control: int i, nLineCount = pmyEdit->GetLineCount(); CString strText, strLine; // Dump every line of text of the edit control. for (i=0;i < nLineCount;i++) { // length of line i: int len = pmyEdit->LineLength(pmyEdit->LineIndex(i)); pmyEdit->GetLine(i, strText.GetBuffer(len), len); strText.ReleaseBuffer(len); strLine.Format(TEXT("line %d: '%s'\n"), i, strText); afxDump << strLine; } #endif
另外一个问题就是:当行数非常多的时候, int len = pmyEdit->LineLength(pmyEdit->LineIndex(i)); 这句就会执行的特别慢,是否有更高效的解决方法呢?
extern CEdit* pmyEdit; // The pointer to my edit control: int i, nLineCount = pmyEdit->GetLineCount();
CString strText, strLine;
// Dump every line of text of the edit control.
for (i=0;i < nLineCount;i++)
{
// length of line i:
int len = pmyEdit->LineLength(pmyEdit->LineIndex(i));
pmyEdit->GetLine(i, strText.GetBuffer(len), len);
strText.ReleaseBuffer(len);
strLine.Format(TEXT("line %d: '%s'\n"), i, strText);
afxDump << strLine;
}
#endif
int len = pmyEdit->LineLength(pmyEdit->LineIndex(i));
这句就会执行的特别慢,是否有更高效的解决方法呢?