• RichEditView自写WriteColorMessage


    nt CIOCPClientView::WriteColorMessage(CString message, COLORREF color)
    {
    int nOldLines = 0, nNewLines = 0, nScroll = 0;
    long nInsertionPoint = 0;
    CHARFORMAT cf;
    // Save number of lines before insertion of new text
    nOldLines = this->GetRichEditCtrl().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 = this->GetRichEditCtrl().GetWindowTextLength();
    this->GetRichEditCtrl().SetSel(nInsertionPoint, -1);
    // Set the character format
    this->GetRichEditCtrl().SetSelectionCharFormat(cf);
    // Replace selection. Because we have nothing
    // selected, this will simply insert
    // the string at the current caret position.
    this->GetRichEditCtrl().ReplaceSel(message);
    // Get new line count
    nNewLines = this->GetRichEditCtrl().GetLineCount();
    // Scroll by the number of lines just inserted
    nScroll = nNewLines - nOldLines;
    this->GetRichEditCtrl().LineScroll(nScroll);
    //PostMessage(WM_VSCROLL, SB_BOTTOM,0); 上面那句改成这句话能提高速度

    char firstline[1024];
    this->GetRichEditCtrl().GetLine(0,firstline);
    if(nNewLines>6)
    {
       this->GetRichEditCtrl().SetSel(0,strlen(firstline ));
       //WriteContentToRTF("old.rtf");
       //this->SetWindowTextA("");
       this->GetRichEditCtrl().ReplaceSel("",0);
    }
    return 0;

    }

    本博客是个人工作中记录,遇到问题可以互相探讨,没有遇到的问题可能没有时间去特意研究,勿扰。
    另外建了几个QQ技术群:
    2、全栈技术群:616945527,加群口令abc123
    2、硬件嵌入式开发: 75764412
    3、Go语言交流群:9924600

    闲置域名www.nsxz.com出售(等宽等高字符四字域名)。
  • 相关阅读:
    hdu Dragon Balls
    acm steps chapter4总结
    bit 最牛的回文
    hdu find the most comfortable road
    hdu Farm Irrigation
    acm steps chapter5总结
    C#日期
    MFC中的CFileFind类
    区别 cfilefind 的三个查询方法 GetFileName (),GetFilePath(),GetFileTitle()
    wubi安装ubuntu时要去官网下载系统映像文件问题的方法
  • 原文地址:https://www.cnblogs.com/zhaogaojian/p/9762036.html
Copyright © 2020-2023  润新知