RichEdit1.SelStart := SendMessage(RichEdit1.Handle, EM_LINEINDEX, 19, 0);
RichEdit1.Perform(EM_SCROLLCARET, 0, 0);
这种用法在2000下还是能滚动的。
你在程序中只要将计算出的位置把19,0替换了就行了。

解决方案 »

  1.   

    function SearchForText_AndSelect(RichEdit: TRichEdit; SearchText: string): boolean; 
    var 
      startpos, position, endpos: integer; 
    begin 
      startpos := 0; 
      with RichEdit do 
      begin 
        endpos := Length(RichEdit.Text); 
        Lines.BeginUpdate; 
        while FindText(SearchText, startpos, endpos, [stMatchCase])<>-1 do 
        begin 
          endpos   := Length(RichEdit.Text) - startpos; 
          position := FindText(SearchText, startpos, endpos, [stMatchCase]); 
          Inc(startpos, Length(SearchText)); 
          SetFocus; 
          SelStart  := position; 
          SelLength := Length(SearchText); 
        end; 
        Lines.EndUpdate; 
      end; 
    end; 
    我没有装xp系统,无法测试。
      

  2.   

    大哥,你这个我不明白RichEdit1.SelStart := SendMessage(RichEdit1.Handle, EM_LINEINDEX, 19, 0),你在程序中只要将计算出的位置把19,0替换了就行了。
    RichEdit1.SelStart不就是要知道的要选定文字的开始处吗,那我怎么知道19,0的位置呢?
    另外那个FindText方法的问题您知道是什么原因吗?