No, this code is wrong. CurItemNo is an index of an item in a document, not an index of a text style.
The resulting code depends on what "current character" mean.
The following code returns the color of the current text style:
Code: Select all
procedure TSDIAppForm.EditorNotasClick(Sender: TObject);
var
tfi:tfontinfos;
i:tcolor;
begin
tfi := estiloeditornotas.TextStyles;
i := tfi.Items[editornotas.[color=red]CurTextStyleNo[/color]].Color;
end;
But a current text style does not necessary equal to the style of text at the caret position. A current text style is a text style that will be applied to new inserted characters.
If you need to know a color of text of the current text item, you can use this code:
Code: Select all
procedure TSDIAppForm.EditorNotasClick(Sender: TObject);
var
i:tcolor;
StyleNo, TextStyleNo: Integer;
begin
StyleNo := estiloeditornotas.CurItemStyle;
if StyleNo>=0 then begin
// this is a text item
TextStyleNo := StyleNo
else if estiloeditornotas.CurrentItem.AssociatedTextStyleNo>=0 then
// this is a tab or a label item
TextStyleNo := estiloeditornotas.CurrentItem.AssociatedTextStyleNo
else
// non-text item like a picture or a table
TextStyleNo := -1;
if TextStyleNo>=0 then
i := estiloeditornotas.TextStyles[TextStyleNo].Color
else
i := clNone;
end;