zoukankan      html  css  js  c++  java
  • 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出售(等宽等高字符四字域名)。
  • 相关阅读:
    OAuth
    PHP获取客户端的真实IP
    负载均衡----实现配置篇(Nginx)
    在线时间戳转换
    使用curl进行模拟登录
    定时任务
    Matplotlib使用教程
    CentOS7.X安装PHP
    Python虚拟环境的搭建与使用
    CentOS7.X安装openssl
  • 原文地址:https://www.cnblogs.com/zhaogaojian/p/9762036.html
Copyright © 2011-2022 走看看