请问有没有对不同设置不同颜色的的仿RichEdit的控件?
在哪儿有下的,或那位大哥有能否发一个给我?
先谢了是否在RichEdit中就可以对每行设置颜色?如果可以请教一下方法

解决方案 »

  1.   

    不好意思
    请问有没有对不同“行”设置不同颜色的的仿RichEdit的控件?
      

  2.   

    直接用RichEdit就可以了:uses RichEdit;procedure TForm1.SetLineColor(lineno: Integer; linecolor: TColor);
    var
      p: Integer;
      fmt: TCharFormat2;
    begin
      with RichEdit1 do begin
        p := Perform(EM_LINEINDEX, lineno, 0);
        SelStart := p;
        SelLength := Length(Lines[lineno]);
        fmt.cbSize := SizeOf(fmt);
        Fmt.dwMask := CFM_BACKCOLOR or CFM_WEIGHT;
        Fmt.crBackColor := linecolor;
        Perform(EM_SETCHARFORMAT, SCF_SELECTION, Integer(@fmt));
      end;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      SetLineColor(0, clRed);  // 设置第1行为红色
    end;需要2.0版本的Riched20.dll支持,Win2000自带,在98下的话可以把2000下的Riched20.dll拷过去覆盖。
      

  3.   

    以下将当前行变为红色:
    procedure TForm1.Button1Click(Sender: TObject);
    var
      x1,y1,x,y:integer;
    begin
      with richedit1 do
      begin
        x1:=selstart;
        y1:=selLength;
        Y := SendMessage(Handle, EM_EXLINEFROMCHAR, 0,SelStart);
        X := (SelStart - SendMessage(Handle, EM_LINEINDEX,Y, 0));
        SelStart :=x1-x;
        Sellength :=Length(lines[y]);
        SelAttributes.size :=20;
        SelAttributes.color :=clRed;
        SelAttributes.name :='宋体';
        SelStart :=x1;
        Sellength :=y1;
        HideSelection :=false;
      end;
    end;