Das ganze mit Toolbar-Buttons:
Delphi-Quellcode:
procedure TForm1.tbbBoldClick(Sender: TObject);
begin
if tbbBold.Down then
Richedit1.SelAttributes.Style := Richedit1.SelAttributes.Style + [fsBold]
else
Richedit1.SelAttributes.Style := Richedit1.SelAttributes.Style - [fsBold];
end;
procedure TForm1.tbbItalicClick(Sender: TObject);
begin
if tbbItalic.Down then
Richedit1.SelAttributes.Style := Richedit1.SelAttributes.Style + [fsItalic]
else
Richedit1.SelAttributes.Style := Richedit1.SelAttributes.Style - [fsItalic];
end;
procedure TForm1.RichEdit1SelectionChange(Sender: TObject);
begin
tbbBold.Down := fsBold in Richedit1.SelAttributes.Style;
tbbItalic.Down := fsItalic in Richedit1.SelAttributes.Style;
tbbUnderline.Down := fsUnderline in Richedit1.SelAttributes.Style;
end;