How to make a fontstyle format brush like in MS Word?
How to make a fontstyle format brush like in MS Word?
Hi, Sergey,
How to make a fontstyle format brush in Richviewedit by using a button, the functionality is just like in Microsoft Word?
I have no any idea of implementing this in my test, can you please help me out?
Andy
How to make a fontstyle format brush in Richviewedit by using a button, the functionality is just like in Microsoft Word?
I have no any idea of implementing this in my test, can you please help me out?
Andy
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
RichViewActions ( http://www.trichview.com/resources/actions/ ) implements something like this. But not exactly like in MS Word (In MS Word, this is a combo button, displaying the last applying color, and it allows to reapply the last color on single click; this is not impemented yet)
Hi, Sergey,
Thank you, but I mean, how to get all the fontstyle for the cursor position in the text, the fontstyle is not limited to color, but all the style like color, fontname, font size etc.
When I get the style and saved it to an object like fs:Tfontstyle, then I can apply this fs to any text selected and change the text selection style exactly like the fontstyle I want.
can there be some methods to do this?
Thank you, but I mean, how to get all the fontstyle for the cursor position in the text, the fontstyle is not limited to color, but all the style like color, fontname, font size etc.
When I get the style and saved it to an object like fs:Tfontstyle, then I can apply this fs to any text selected and change the text selection style exactly like the fontstyle I want.
can there be some methods to do this?
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Can you help me out?
HI, Sergey-
After some tries I still cannot find a way to make fontstyle format brush like in MS Word?
How can I get all the font style which i selected and how to apply them to another text selection?
Can you possibily indicate me with code samples?
Thank you very much!
Andy
After some tries I still cannot find a way to make fontstyle format brush like in MS Word?
How can I get all the font style which i selected and how to apply them to another text selection?
Can you possibily indicate me with code samples?
Thank you very much!
Andy
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Ok, let we have RichViewEdit1: TRichViewEdit, linked to RVStyle1: TRVStyle.
Reading current text format:
Applying to the selection:
On destroying the form:
Code: Select all
TextStyle: TFontInfo; // form's variable
Code: Select all
TextStyle.Free;
TextStyle := TFontInfo.Create(nil);
TextStyle.Assign(RVStyle.TextStyles[RichViewEdit1.CurTextStyleNo]);
Code: Select all
var StyleNo: Integer;
if TextStyle<>nil then begin
StyleNo := RVStyle1.TextStyles.FindSuchStyle(0, RVAllFontInfoProperties);
if StyleNo<0 then begin
RVStyle1.TextStyles.Add;
StyleNo := RVStyle1.TextStyles.Count-1;
RVStyle1.TextStyles[StyleNo].Assign(TextStyle);
RVStyle1.TextStyles[StyleNo].Standard := False;
end;
RichViewEdit1.ApplyTextStyle(StyleNo);
end;
Code: Select all
TextStyle.Free;
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Well, there is a simpler solution.
On form's creation:
Reading the current text format:
Applying to the selection:
The only problem with this solution is: the stored value of StyleNo becomes invalid after creating a new document (File | New) or loading another document (File | Open), so you should reset it to -1.
Code: Select all
StyleNo: Integer; // form's variable
Code: Select all
StyleNo := -1;
Code: Select all
StyleNo := RichViewEdit1.CurTextStyleNo;
Code: Select all
if StyleNo>=0 then
RichViewEdit1.ApplyTextStyle(StyleNo);
Thank you, Sergey!
Hi, Sergey,
I have done with the font format brush, thank you for your kind hints and help.
Andy
I have done with the font format brush, thank you for your kind hints and help.
Andy