void CExampleViewView::OnInitialUpdate()
{
CView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
CRect rcClient;
GetClientRect(rcClient);
if(m_ctrlEdit) delete m_ctrlEdit;
m_ctrlEdit = new CEdit();
m_ctrlEdit ->Create(ES_MULTILINE|WS_CHILD|WS_VISIBLE|WS_HSCROLL|ES_AUTOHSCROLL|WS_VSCROLL|ES_AUTOVSCROLL,rcClient, this, 201);
CExampleViewDoc* pDoc = GetDocument();
CString str;
int nLines = (int)pDoc->m_strContent.GetSize();
for(int i=0;i<nLines; i++)
{
str = str + pDoc->m_strContent.GetAt(i);
str = str + "\r\n";
}
m_ctrlEdit->SetTabStops(16);
m_ctrlEdit->SetWindowText(str);
}
这一句
str = str + "\r\n";改成
应该是由于开启了Unicode。所以CString内部类型实际是wchar_t而不是char,你在操作裸字符串的时候也要加上_T()宏以表示是宽字符集。