1.首先建立一个MFC单文档项目

2.类向导中向视图类中添加一个变量 CPoint ptCharacter;

3.在视图类的构造函数中初始化ptCharacter

 CMyView::CMyView()
{
 // TODO: add construction code here
     ptCharacter.x=0;
       ptCharacter.y=0;
}

3.在WM_CHAR消息响应函数OnChar中实现字符的显示以及换行。代码如下

 void CMyView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
 // TODO: Add your message handler code here and/or call default
 if(nChar==13)
 {
  ptCharacter.x=0;
  ptCharacter.y=ptCharacter.y+25;
 }else
 {
  CClientDC dc(this);
  dc.TextOut(ptCharacter.x,ptCharacter.y,(LPCTSTR)&nChar);
  CSize textsize;
  textsize=dc.GetTextExtent((LPCTSTR)&nChar);
         ptCharacter.x=ptCharacter.x+textsize.cx;
 }

 CView::OnChar(nChar, nRepCnt, nFlags);
}

4.运行项目