Hi
Does the button copy/apply style exist ?
Thanks
Copy and apply style button
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
I can explain how to store the current text formatting and how to apply it to selected text.
This code stores only text formatting, without paragraph formatting.
You need two variables to store formatting:
Storing:
Applying:
When the form is destroyed:
This code stores only text formatting, without paragraph formatting.
You need two variables to store formatting:
Code: Select all
TextStyle: TFontInfo;
StyleTemplateName: TRVStyleTemplateName;
Code: Select all
var ST: TRVStyleTemplate;
if TextStyle=nil then
TextStyle := TFontInfo.Create(nil);
TextStyle.Assign(RVStyle1.TextStyles[RichViewEdit1.CurTextStyleNo]);
ST := RVStyle1.StyleTemplates.FindItemById(TextStyle.StyleTemplateId);
if ST<>nil then
StyleTemplateName := ST.Name
else
StyleTemplateName := '';
Code: Select all
var ST: TRVStyleTemplate;
if TextStyle<>nil then begin
TextStyle.ParaStyleTemplateId := RVStyle1.TextStyles[RichViewEdit1.CurTextStyleNo]).ParaStyleTemplateId;
ST := RVStyle1.StyleTemplates.FindItemByName(StyleTemplateName);
if ST<>nil then
TextStyle.StyleTemplateId := ST.Id
else
TextStyle.StyleTemplateId := -1;
RichViewEdit1.ApplyTextStyle(RVStyle1.FindTextStyle(TextStyle));
end;
Code: Select all
TextStyle.Free;