zoukankan      html  css  js  c++  java
  • VC编辑框(EDIT)的自动换行、自动滚屏 、到指定行数自动清空

    在自动换行设置的时候,要在EDIT控件的属性中选中"multiline"的属性和Auto_HScroll、Vertical scroll。.

    http://blog.sina.com.cn/s/blog_41604f160100877c.html

    经过多次测试,总结出VC编辑框(EDIT)的自动换行与自动滚屏的方法。

    方法一:(当EDIT映射到一CString时)

    m_String = m_String + sNewString + "\r\n" //自动换行(其中m_String是EDIT筐所关联的CString对象)
    UpdateData(false);

    此法只能做到自动换行,不会自动滚屏到最后一行。

    方法二:(当EDIT映射到一EDIT时)
    m_Edit.SetSel(-1, -1); //自动滚屏(其中m_Edit是EDIT筐所关联的EDIT控制对象)
    m_Edit.ReplaceSel(sNewString+"\r\n"); //自动换行

    此法可以做到自动换行,并自动滚屏到最后一行。

    以上,m_String、m_Edit.分别为给编辑框添加的成员变量;sNewString 为要显示的字符串

    方法三:到200行时将所有内容清空

    int iLineNum=m_EditLog.GetLineCount();
     if(iLineNum<=200)
     {
     m_EditLog.SetSel(-1, -1);
     m_EditLog.ReplaceSel(str+"\r\n\r\n");
     }
     
     else
     {
     m_EditLog.SetSel(0, -1);
     m_EditLog.Clear();
     
     }

    取自msdn

    void SetSel( int nStartChar, int nEndChar, BOOL bNoScroll = FALSE );

    Parameters

    nStartChar

    Specifies the starting position. If nStartChar is 0 and nEndChar is –1, all the text in the edit control is selected. If nStartChar is –1, any current selection is removed.

    nEndChar

    Specifies the ending position.

  • 相关阅读:
    CSS3弹性盒布局方式
    Vue知识点(面试常见点)
    h5新增加的存储方法
    前端常用插件
    Git 及 GitHub 使用
    Express 框架
    angular.js 教程 -- 实例讲解
    Windows右键添加VSCode启动
    Windows平台SSH登录Linux并使用图形化界面
    10_Linux yum命令
  • 原文地址:https://www.cnblogs.com/mfryf/p/2349732.html
Copyright © 2011-2022 走看看