怎样在一个MEMO控件中设置两种或两种以上字体?
1、就象WORD那样,可以把选中的字的字体及大小随意设置。页其它的字体及大小不变。
2、对于MEMO中的字,对一些规定的字设置为一种字体,而其它的字设置为另一种字体?如把大写字母设置为正体,把小写字母设置为斜体。

解决方案 »

  1.   

    memo可以吗?richedit倒是可以。
      

  2.   

    给你一个函数,这个函数是查找richedit里的所有某个字符串,并用另外一个字符串替换掉,当然对单个字符也有效,
      相信你能很容易看明白,并且很容易修改一下。
    function TForm1.Search_And_Replace(RichEdit: TRichEdit; SearchText,
      ReplaceText: 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);
          richedit.clearselection;
          SelText := ReplaceText;
        end;
        Lines.EndUpdate;
      end;
    end;