我得问题是这样的:
我在Dialog上插入了一个RichEdit控件m_EditPan,但是我在代码中控制输入,比如我写一个函数,m_EditPan.Write ( ... ),它就把我写的参数,写到了控件框中,并且自动换行。
请问谁知道,提示一下。谢谢

解决方案 »

  1.   

    我只知道在CView下,可以用pDC->TextOut()可以很好的控制,在RichEdit却没有很好的函数。
      

  2.   

    m_EditPan.Write ( "..."+"/r/n" );
      

  3.   

    m_EditPan.SetWindowText( "帮个忙。在线等待" ).
      

  4.   

    SetWindowText("..."+"\r\n" );行不行?
      

  5.   

    很简单解决方法:
    str1+=stradd;
    SetDlgItemText(控件ID ,str1);
      

  6.   

    void myDialog::WriteToRichEdit( CString & iText )
    {
       CString WindowText;   m_EditPan.GetWindowText( WindowText );   WindowText += iText;   m_EditPan.SetWindowText( WindowText );
    }
      

  7.   

    Also, add "\r\n" to the end of your string so you could have multiple lines.
      

  8.   

    是吗?Also, add "\r\n" to the end of your string so you could have multiple lines.
    有效吗?不行吧!他不会换行,而是直接显示“\r\n”。
      

  9.   

    long l = rRichEdit.GetTextLength();
    rRichEdit.SetSel(l, l);
    rRichEdit.ReplaceSel(_T(“帮助\r\n”));
      

  10.   

    不要用setwindowtext
    用ReplaceSel
      

  11.   

    jerrytse(聪明笨伯) 的方法好像可以,不知道会不会把前面部分字符覆盖。
      

  12.   

    我自己写好了一个,只不过有一点笨,用到了一个文件。用StreamIn
      

  13.   

    是这样的:大家可以看看Msdn上的例子,几乎差不多。
    DWORD CALLBACK CMainFrame::StreamInCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
    {
    CFile* pFile = (CFile*) dwCookie;
    *pcb = pFile->Read(pbBuff, cb);
    return 0;
    }
    BOOL CMainFrame::Write(CString strMsg)
    {
    char str[10]="123456789";
    CFile cFile(TEXT("record.txt"), CFile::modeWrite);
    cFile.Seek(0,CFile::end);
    //添加时间
    CTime time = CTime::GetCurrentTime();
    CString strTime = time.Format("%H:%M:%S");
    strTime += TEXT("   ");
    strTime += strMsg;
    strMsg = strTime; 
    //添加回车
    char cc = '\n';
    strMsg+=cc; cFile.Write(strMsg.GetBuffer(strMsg.GetLength()),strMsg.GetLength());
    cFile.Close();
    //输出到RichEdit
    EDITSTREAM es;
    cFile.Open(TEXT("record.txt"), CFile::modeRead);
    es.dwCookie = (DWORD)&cFile;
    es.pfnCallback = StreamInCallback; 
    m_EditPan.StreamIn(SF_TEXT, es);
    cFile.Close();
    return TRUE;
    }
      

  14.   

    这样每次只要调用Write就可以了,献丑了。呵呵
      

  15.   

    还有一个问题,怎么使m_EditPan自动出现滚动条,我这样写的,但是还是没有,为什么?
    m_EditPan.Create(WS_CHILD|WS_VISIBLE|ES_AUTOVSCROLL|ES_WANTRETURN|
    ES_AUTOVSCROLL|ES_MULTILINE|ES_READONLY,
    CRect(0,0,100,100),&m_wndView,1);