Page 1 of 1
Issue with ScaleRichView
Posted: Fri Dec 09, 2016 12:14 pm
by Gizz3
Hello!
My company purchased like 10 years ago or so the 1.0 version of richview. We are now planning to purchase the last version and migrate to scalerichview.
Playing with the demos and trials i only see one big barrier.
We were using 3 richviewedits for body,header and footer with theirs own styles. Our styles are defined BEFORE the form shows where we make the preprocessing , so StartEditing(srvHeader) is not a option.
I have tried using ExternalRVStyleHeader, Subdocuments.MainStyle and RVHeader.Style, but all of them got replaced the moment you start editing the header.
I also noticed it got deleted if you do "format", so maybe i'm deleting it somehow and i don't know. If i check right before editing header it seems fine though.
The question would be:
¿Can i still create a RVStyle for header in code before the form shows on ScaleRichView? ¿What function replace the header style?
Thank you for reading.
Posted: Sun Dec 11, 2016 10:07 am
by Sergey Tkachenko
You are right, in the new version, when a header editing is activated, styles from the proper SRV.SubDocuments[].GetRVStyle are copied to SRV.RVHeader.Style.
The solution is assigning styles of SRV.SubDocuments[] when a new document is created.
Normally, a new document is created using rvActionNew.Execute or rvActionOpen.LoadFile.
In the both cases, rvActionNew.OnNew event occurs.
In this event, you can assign default properties of SRV.SubDocuments[].GetRVStyle for all subdocuments.
Posted: Mon Dec 12, 2016 7:01 am
by Gizz3
¿Do you have any demo/code that shows how to use rvaction events?
You can assign rvactions to buttons easy, but i don't get how to use the events and don't see it on the demo.
Thank you.
Posted: Mon Dec 12, 2016 7:58 am
by Gizz3
I found it
srvActionsResource.rvActionNew1.OnNew:=eventActionOnNew;
http://www.trichview.com/help-actions/i ... _onnew.htm
The problem persist because this is not being called, ill test it a little more.
Posted: Mon Dec 12, 2016 8:27 am
by Gizz3
Sadly, we don't use rvActionNew.Execute or rvActionOpen.LoadFile. We are not using any rvAction at the moment, the code is pretty old.
¿Is there any other way without actions?
Posted: Mon Dec 12, 2016 10:26 am
by Sergey Tkachenko
Do you use RichViewActions?
If you use New, Open, Save, SaveAs actions, you should start either from executing New or from loading a file using Open, to associate the editor with a file.
If you do not use these actions, you create your document yourself. Place the code for assigning styles of SRV.SubDocuments.GetRVStyle where you create a new document (in FormCreate?)
Posted: Mon Dec 12, 2016 1:12 pm
by Gizz3
Yes i think i got it.
All is done manually, probably using RichViewActions would cut the size of the code in half.
Not probably the best way to do it but what i did is save the style and add the missing textstyles onChangeActiveEditor. I'm still not sure how to modify SRV.SubDocuments.GetRVStyle as you said but this works and its all i need to show the editor to the boss. If we buy we will talk again and will discuss the best way
Thank you for your time.
PD: Sorry for bad english.
Posted: Mon Dec 12, 2016 7:16 pm
by Sergey Tkachenko
OnChangeActiveEditor occurs every time when you switch between the main document, footer, header, text box, footnote, endnote.
It may be used as a quick and dirty solution, but should not be used in the actual application to modify styles, because it may occur after header/footer is already edited.
You need to define styles when your editor is initialized.
For example. Create a new application. Place SRichViewEdit1: TSRichViewEdit on a form. Add the code in FormCreate:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
with SRichViewEdit1.SubDocuments[srvhftNormalHeader].GetRVStyle do
begin
TextStyles.Clear;
TextStyles.Add.Color := clBlue;
end;
SRichViewEdit1.Format;
end;
Run the application.
Start editing the header. You will see its text is blue.