![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
RichEdit [D6, WinXP]
dm37 © (2005-02-28 10:35:00)Подскажите, как в RichEdit добавлять текст с атрибутами (color,font_name,style), например:
RichEdit.Lines.Add('asdf'); // красный цвет символов
RichEdit.Lines.Add('ghjk'); // зеленый цвет символов
и т.д.
Нужно самому ставить теги или есть свойства объекта?
dm37 (2005-02-28 13:40:00) [1]Спасибо, все заработало
Erik1 (2005-02-28 12:30:00) [2]А также:
procedure TAsp.AddText(const Text: WideString; Attrib: Attributs;
tSize: Byte; const FontName: WideString);
Var MyStyle: TFontStyles; MyFont: String;
MySize: Byte;
MyAlignment: TParaAlignment;
begin
if Invisable = nil Then exit;
// MyAlignment := MyAlignment - MyAlignment;
if Attrib <> 0 Then begin
if (stNormal and Attrib) = stNormal then
begin
MyStyle := MyStyle - MyStyle;
MyFont := 'Times New Roman'; MySize := 10;
MyAlignment := paLeftJustify;
end
else begin
With Invisable.RichEdit.DefAttributes do begin
MyStyle := Style;
MyFont := Name;
MySize := Size;
end;
MyAlignment := Invisable.RichEdit.Paragraph.Alignment;
end;
if (stBold and Attrib) = stBold Then MyStyle := MyStyle + [fsBold];
if (stItalic and Attrib) = stItalic Then MyStyle := MyStyle + [fsItalic];
if (stUnderline and Attrib) = stUnderline Then MyStyle := MyStyle + [fsUnderline];
if tSize <> 0 Then MySize := tSize;
if FontName <> '' Then MyFont := FontName;
With Invisable.RichEdit do begin
WordAttributes.Style := MyStyle;
WordAttributes.Name := MyFont;
WordAttributes.Size := MySize;
WordAttributes.Charset := 186; //BALTIC_CHARSET Replase Cyrilic
DefAttributes.Style := MyStyle;
DefAttributes.Name := MyFont;
DefAttributes.Size := MySize;
DefAttributes.Charset := 186; //BALTIC_CHARSET Replase Cyrilic
end;
end;
With Invisable.RichEdit.Paragraph do begin
Case ((agCenter or agLeft or agRight) and Attrib) of
agLeft: MyAlignment := {$IFDEF RxLib}paLeftJustify;{$ELSE}taLeftJustify;{$ENDIF}
agCenter: MyAlignment := {$IFDEF RxLib}paCenter;{$ELSE}taCenter;{$ENDIF}
agRight: MyAlignment := {$IFDEF RxLib}paRightJustify;{$ELSE}taRightJustify;{$ENDIF}
end;
Alignment := MyAlignment;
if (pgBullet and Attrib) = pgBullet Then Numbering := nsBullet else Numbering := nsNone;
end;
Invisable.RichEdit.Lines.Add(Text);
end;
КаПиБаРа (2005-02-28 10:39:00) [3]F1 - TRichEdit.SelAttributes