Page 1 of 1

RichViewActions/ScaleRichView (Table Borders increases)

Posted: Thu Apr 27, 2017 7:05 pm
by Tavo
Hello!! I'm using RichViewActions/ScaleRichView
I'm testing a modified version of ActionTest (RichViewActions) within an application I'm developing.
I encounter the following problem: If you enter a table with the default values, the table are perfect. If you enter a second table with the default values its thickness doubles. The third table is triplicated. And so.
I would be grateful if you could give me any clue as to where to look for my mistake.
I'm sure I made a mistake and now this works like that, but I do not know where to look. Maybe I made a mess with ControlPanel, I dont' know.
Apologies for my bad english I hope they understand me.

Re: RichViewActions/ScaleRichView (Table Borders increases)

Posted: Fri Apr 28, 2017 8:43 am
by Sergey Tkachenko
Please give me step-by-step instructions how to reproduce this problem.

If I run ScaleRichView ActionTest demo and insert 3 tables one after one, they look identical.

Re: RichViewActions/ScaleRichView (Table Borders increases)

Posted: Tue May 02, 2017 5:17 pm
by Tavo
Hello Sergey
Thank you for answering me. The truth is that I made many modifications and I do not know what is causing these problems.
First I tell you what I did in my application: I used TForm3.pas from the ActionTest.dpr project and I made it into a TFrame. So, I can use it in different places.
Since TFrame has no OnCreate event, I wrote an Init () function that I called from the OnCreate event of the form containing the TFrame.

One of the uses I give is as follows: an RVF file editor in an MDI window. That way you can create more than one instance of that window at the same time.
To reproduce this problem, I create an instance of the "Editor" window, there I enter a table (there could be three, they would be the same with each other). Leaving the first window open I create a second window, there I enter a table and then this table is thicker than in the first window. If I created a third window, a table there would be even thicker.
I think there is some error initialization of variables. I do not know where to look.

My project has a line in the DPR file:

Application.CreateForm (TrvActionsResource, rvActionsResource);

That is, there is only one instance of TrvActionsResource.
Maybe I can provide one more data so you can think about the problem. Just tell me and I'll do it.


Thank you very much for your help.
Apologies for my bad english
A greeting from Buenos Aires.
Tavo

Re: RichViewActions/ScaleRichView (Table Borders increases)

Posted: Tue May 02, 2017 5:28 pm
by Sergey Tkachenko
If you can create a project reproducing this problem (as simple as possible), please send it to me.

Re: RichViewActions/ScaleRichView (Table Borders increases)

Posted: Wed May 24, 2017 5:57 pm
by Tavo
Sergey, thank you for answering. Your answer made me work. :lol: :lol: :lol: :lol: :lol:
My project is very large and all its parts are interrelated. It's very difficult to send you the whole project.

Well... I got more information about the problem. I can eliminate the symptom but I do not know the reason for it.

At first I did my best but I could not reproduce the error in a small project:
Since I did not know what part of the project was causing the problem, I tried to do something similar to what I have in my main project.

I took the project "ActionTest" (ScaleRichView) and modified two things:
  • I converted the Form3 form into a TFrame (this is how it works in my project)
    I inserted that frame into a Form2 form (FormStyle = fsMDIChild)
    I added a MainForm Form1 from where I can create more than one instance (MDI) of TForm2
But I can not reproduce the problem. In this project everything works well !!!!

I came to the conclusion that there was something that was increasing in each creation of the Editor window. Since TFrame (Form3.pas) has no OnCreate event, I wrote an Init() function that I called from the OnCreate event of the form TForm2. I searched within this function and found this:

RVA_ConvertToTwips(srvActionsResource) ;

SrvActionsResource is the name of the unique instance of TsrvActionsResource throughout the project. So every time I created a New Form2 Instance, RVA_ConvertToTwips was executed again. I do not quite understand why I put that call there.

In creating the first window:

dmActionsSRV.srvActionsResource.rvActionInsertTable1.BorderWidth = 15

In creating the second window:

dmActionsSRV.srvActionsResource.rvActionInsertTable1.BorderWidth = 225

In third: 3375 in Fourth 50625

In conclusion: Each RVA_ConvertToTwips execution multiplies BorderWidth by 15.

Code: Select all

procedure TrvActionInsertTable.ConvertToTwips;
var
  UnitsProgram: TRVStyleUnits;
begin
  UnitsProgram := GetControlPanel.UnitsProgram;
  if BestWidth > 0 then
    BestWidth := TRVStyle.GetAsTwipsEx(BestWidth, UnitsProgram);
  BorderWidth := TRVStyle.GetAsTwipsEx(BorderWidth, UnitsProgram); // This call increases BorderWidth 
If I deleted the call to RVA_ConvertToTwips(srvActionsResource) everything returned to normal
If I move the call to RVA_ConvertToTwips(srvActionsResource) to TsrvActionsResource.Oncreate all of tables will have a BorderWidth=15 in any window.

Sorry for my english. Thanks for readme.