用richedit;先自定义函数如下:
function TMainForm.CurrText: TTextAttributes;
begin
if Editor.SelLength > 0 then Result := Editor.SelAttributes
else Result := Editor.DefAttributes;
end;
然后用某个事件触发对选中字体的颜色进行改变
procedure TForm1.button1click(sender: TObject);
begin
currtext.color := clred;
end;