CEditView问题
建立一个mfc单文档应用程序
最后一步从 CEditView继承
在菜单里面新增一个菜单项
写如下代码
可是却并不能得到所选的字符串
debug 发现 取得某一行长度的 nn 始终只为第一行的长度
怎么回事??
多谢
void CSCMView::OnSel()
{
// TODO: Add your command handler code here
CEdit& theEdit = GetEditCtrl();
int nline = theEdit.GetLineCount();
CString str = "" ;
LPTSTR lp = "abcdefghghidiidlaadfafafafafaf";//new TCHAR[1024];
// 这段代码来自 msdn
int i, nLineCount = theEdit.GetLineCount();
CString strText, strLine;
// Dump every line of text of the edit control.
for (i=0;i < nLineCount;i++)
{
int nn = theEdit.LineLength(i);
theEdit.GetLine(i, strText.GetBuffer(theEdit.LineLength(i)));
strText.ReleaseBuffer();
str += strText;
}
AfxMessageBox(str);
}