//***********************************
//试试这个,可以读取RICHEDIT中的属性,
//你可以通过设置SELSTART和SELLENGTH逐个
//处理你的东东.
//TEST.RTF是一个富文本格式,你可以试试
//在其中加入不同的颜色,LABEL的颜色跟着
//你文本的颜色改变.
//***********************************unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ComCtrls;type
  TForm1 = class(TForm)
    RichEdit1: TRichEdit;
    Label1: TLabel;
    procedure RichEdit1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.DFM}procedure TForm1.RichEdit1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  NowColor:TColor;
begin
With RichEdit1 do begin
   NowColor:=RichEdit1.SelAttributes.Color ;
  end;  Label1.Font.Color :=nowColor;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
Richedit1.Lines.LoadFromFile ('C:\test.rtf');
end;end.

解决方案 »

  1.   

    The EM_GETCHARFORMAT message determines the current character formatting in a rich edit control.EM_GETCHARFORMAT  
    wParam = (WPARAM) (BOOL) fSelection; 
    lParam = (LPARAM) (CHARFORMAT FAR *) lpFmt; 
     ParametersfSelectionValue specifying whether to get the default character formatting or the current selection's character formatting. If this parameter is zero, the default formatting is returned. Otherwise, the current selection's formatting is returned.lpFmtPointer to a CHARFORMAT structure to fill in. If the selection formatting is being retrieved, the structure receives the attributes of the first character, and the dwMask member specifies which attributes are consistent throughout the entire selection. Return ValuesReturns the value of the dwMask member of the CHARFORMAT structure.
      

  2.   

    如果SelLength=0
    richedit.DefAttributes.Color...Name...Size
    否则使用
    Richedit.SelAttributes.Color...Name...Size
      

  3.   

    在RichEdit的SelectionChange事件中可捕获到当前文本的属性。
    例如,在窗体上放一个panel,Caption设为Testfunction CurrentText:TTextAttributes;
    begin
      if Richedit.SelLength=0 then
        Result:=Richedit.DefAttributes
      else
       Result:=RichEdit.SelAttributes;
    end;procedure TForm1.RicheditSelectionChange(Sender:TObject);
    begin
      With CurrentText do
      begin
        Panel1.Color:= Color;
        Panel1.Font.name:=Name;
        Panel1.Font.Size:=Size;
        panel1.font.style:=....
       ....
      end;
    end;
    在Richedit中写几行字,设置不同的颜色、字体,当您移动光标时,Panel1的字体、颜色会跟着改变,这应该算是取得了您要的吧,至于知道了颜色、字体,大小,接下来要干什么,就看您的了。:-)勿勿写了几行,未运行测试,应该没问题吧。