I am trying to add a resource in my editor, protect functions.
First, is there any action that does this?
If not, I tried this code:
Code: Select all
procedure TForm1.rveStyleConversion(Sender: TCustomRichViewEdit; StyleNo,
UserData: Integer; AppliedToText: Boolean; var NewStyleNo: Integer);
var FontInfo: TFontInfo;
begin
FontInfo := TFontInfo.Create(nil);
try
FontInfo.Assign(rvs.TextStyles[StyleNo]);
case UserData of
TEXT_PROTEGE:
FontInfo.Protection := [rvprModifyProtect];
TEXT_BOLD:
if btnBold.Down then
FontInfo.Style := FontInfo.Style+[fsBold]
else
FontInfo.Style := FontInfo.Style-[fsBold];
end;
NewStyleNo := rvs.TextStyles.FindSuchStyle(StyleNo,FontInfo,RVAllFontInfoProperties);
if NewStyleNo=-1 then begin
rvs.TextStyles.Add;
NewStyleNo := rvs.TextStyles.Count-1;
rvs.TextStyles[NewStyleNo].Assign(FontInfo);
rvs.TextStyles[NewStyleNo].Standard := False;
end;
finally
FontInfo.Free;
end;
procedure TForm1.rveCurTextStyleChanged(Sender: TObject);
var fi: TFontInfo;
begin
IgnoreChanges := True;
btnBold.Down := fsBold in fi.Style;
btProtege.Down := fi.Protection = [rvprModifyProtect];
IgnoreChanges := False;
end;
thanks