m_edit.SetSel(-1,-1);
m_edit.ReplaceSel("dfasfsdfdf");
这样做并不能滚动到当前光标处,文本是上去了,可是都是在后面,
没有自动滚动,这是为什么?

解决方案 »

  1.   

    m_edit.SetSel(0,-1);
    m_edit.SetSel(-1,-1);
      

  2.   

    是不是因为当前控件的焦点不在RECHEDIT上面?
      

  3.   

    我总是移动到最后
    m_edit.SetSel( 1000000,1000000 );
    m_edit.Replace....
      

  4.   

    看看你的CRichEdit的属性设置有没有问题
      

  5.   

    m_edit.SetSel(-1,-1);这样写,当然是最最后面了
    属性设置,是多行的
      

  6.   

    CString string;输入第一行String1的时候:
    m_edit.SetWindowText(String1 + "\r\n");
    输入第二行String2的时候:
    m_edit.GetWindowText(string);
    string += String2 + "\r\n";
    m_edit.SetWindowText(string);
    m_edit.SetSel(-1,-1);
    之后类似
      

  7.   

    数据量很大的时候,就不灵光了,我用rich edit的目的就是对付很大的数据,
    否则我就用cedit了。
      

  8.   

    ScrollLine()可以滚动,可是做法并不优美
      

  9.   

    滚屏的时候如果直接通过计算出当前视图中的第一个可见行与要滚动的目标行之间的偏差,再调用ScrollLine()是很难达到你的要求的,而且有时候(80%左右)滚屏不准确,这时可以通过:
                        [先滚到第一行,然后再从第一行滚到想要的行]
    的方法达到要求,这个实现起来较简单,只要获取到当前光标所在行就行了。这是本人的一点经验。
    如果有什么不明白的地方请帖出来,正好这两天较闲。
      

  10.   

    override PreTranslateMessage(MSG* pMsg)
        if(pMsg->message==WM_MOUSEMOVE)
        {
    CPoint cursorpos;
    GetCursorPos(&cursorpos);
    CPoint relativepos;
    //get coordinate of cursor position relative to the rich edit control
    ...
    long cindex=CRichEditCtrl::CharFromPos(relativepos);
    long line=CRichEditCtrl::LineFromChar(cindex);
    }
      

  11.   

    计算位置,然后进行scroll,总感觉很不方便,能不能模拟
    ctrl + end 来实现滚动到最后面?
      

  12.   

    ctrl + end 事实上也是计算位置然后滚动,两个方法:
    1)象你说的那样发送消息;
    2)CRichEditCtrl::GetLineCount
    int GetLineCount( ) const;Return ValueThe number of lines in this CRichEditCtrl object.ResCall this function to retrieve the number of lines in the CRichEditCtrl object.For more information, seeEM_GETLINECOUNT in the Win32 documentation.
    ////////////////////////////////////////////////////////////////////
    CRichEditCtrl::LineScroll
    void LineScroll( int nLines, int nChars = 0 );ParametersnLinesSpecifies the number of lines to scroll vertically.nCharsSpecifies the number of character positions to scroll horizontally. This value is ignored if the rich edit control has either the ES_RIGHT or ES_CENTER style. Edit styles are specified in Create./////////////////////////////////////////////////////////////
    ////////////////实现/////////////////////////////////////////
    LineScroll(0);
    LineScroll(GetLineCount( ));
    //Over.
    //先获取控件指针这个没问题吧