本帖最后由 qq361301276 于 2009-12-30 11:07:22 编辑

解决方案 »

  1.   

    m_richEdit.SetWindowText(_T("dfsafda5fjdsaojfoajguaenogdjuao9eongodaj")); 放在最后呢
      

  2.   

    CHARFORMAT cf;
    ZeroMemory(&cf, sizeof(CHARFORMAT));
    cf.cbSize = sizeof(CHARFORMAT);
    cf.dwMask = CFM_BOLD | CFM_COLOR | CFM_FACE |
    CFM_ITALIC | CFM_SIZE | CFM_UNDERLINE;
    cf.dwEffects = 0;
    cf.yHeight = 180;
    cf.crTextColor = RGB(255, 255, 255); 
    strcpy(cf.szFaceName ,_T("宋体"));
    m_edit.SetSel(0, 5);
    m_edit.SetSelectionCharFormat(cf);
      

  3.   

    BOOL CDlgDlg::OnInitDialog()
    {
     
    // bool b1=AfxInitRichEdit();      //调试时,b1为TRUE 


    CDialog::OnInitDialog();
    m_richEdit.SetWindowText(_T("dfsafda5fjdsaojfoajguaenogdjuao9eongodaj")); 
    CHARFORMAT cf; 
    ZeroMemory(&cf, sizeof(CHARFORMAT)); 
    cf.cbSize = sizeof(CHARFORMAT); 
    cf.dwMask =  CFM_COLOR ; 
    cf.dwEffects=~CFE_AUTOCOLOR; 
    cf.dwEffects = 0; 
    cf.crTextColor = RGB(255,0,0); //文字颜色 
    m_richEdit.SetSel(1,8); //设置处理区域 
    bool b=m_richEdit.SetSelectionCharFormat(cf);  //调试时,b始终为False,SetWordCharFormat,SetDefaultCharFormat之类的函数都不能成功执行 -----------
    BOOL CDlgApp::InitInstance()
    {
    AfxEnableControlContainer();
    AfxInitRichEdit();我这可以
      

  4.   

    技术可行,符合你的要求吗?如果符合要求请结贴,如果还有新问题,且有代码需要上传:请把代码压成*.rar当附件发在何丹的论坛上.压代码前,请先删除debug,release文件夹,及*.opt,*.ncb,*.plg,*.aps. 如果不想注册,可用临时号,帐号和密码都是test2
      

  5.   


    // 一直在用她!int CXXDlg::AppendToLog(CString str, COLORREF color)
    {
    int nOldLines = 0, nNewLines = 0, nScroll = 0;
    long nInsertionPoint = 0;
    CHARFORMAT cf; // Save number of lines before insertion of new text
    nOldLines = m_LogEdit.GetLineCount(); // Initialize character format structure
    cf.cbSize = sizeof(CHARFORMAT);
    cf.dwMask = CFM_COLOR;
    cf.dwEffects = 0; // To disable CFE_AUTOCOLOR
    cf.crTextColor = color; // Set insertion point to end of text
    nInsertionPoint = m_LogEdit.GetWindowTextLength();
    m_LogEdit.SetSel(nInsertionPoint, -1);    //  Set the character format
        m_LogEdit.SetSelectionCharFormat(cf); // Replace selection. Because we have nothing selected, this will simply insert
    // the string at the current caret position.
    m_LogEdit.ReplaceSel(str); // Get new line count
    nNewLines = m_LogEdit.GetLineCount(); // Scroll by the number of lines just inserted
    nScroll = nNewLines - nOldLines;
    m_LogEdit.LineScroll(nScroll); return 0;
    }
      

  6.   

    不行
    在我机上,SetSelectionCharFormat(cf)还是执行不了
      

  7.   


    它就是SetSelectionCharFormat(cf)没有成功,返回值每次都是0,都不知是不是系统问题。我用的是Vista全部项目代码已在http://hedanwang.cn/bbs/dispbbs.asp?boardid=17&Id=9135
    用户名和密码都是test2