Issue with ScaleRichView

General TRichView support forum. Please post your questions here
Post Reply
Gizz3
Posts: 5
Joined: Fri Dec 09, 2016 12:00 pm

Issue with ScaleRichView

Post 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.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
Gizz3
Posts: 5
Joined: Fri Dec 09, 2016 12:00 pm

Post 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.
Gizz3
Posts: 5
Joined: Fri Dec 09, 2016 12:00 pm

Post 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.
Gizz3
Posts: 5
Joined: Fri Dec 09, 2016 12:00 pm

Post 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?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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?)
Gizz3
Posts: 5
Joined: Fri Dec 09, 2016 12:00 pm

Post 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 :D
Thank you for your time.

PD: Sorry for bad english.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
Post Reply