Page 1 of 2

Interface is frozen when loading a big file

Posted: Wed Jul 16, 2008 8:21 am
by AutoCorect
Hi.
A significant part of the loading time for rtf files is taken in my program by the SetRVMargins procedure. But during this the main interface is frozen and I can't show any progress to the user (with a progressbar).
For this I need that SetRVMargins to be modified to work with OnProgress event (like RichViewEdit.LoadRtf/LoadRTFFromStream does). Or a new event, as long as the progress is smooth/linear.
Can you do that? Or at least show me how to implement myself..

Thank you in advance.

Posted: Wed Jul 16, 2008 1:28 pm
by proxy3d
You can send me RTF a file, call SetRVMargins at which lasts a lot of time?
Or a problem what SetRVMargins does not return management at once?

Posted: Wed Jul 16, 2008 2:09 pm
by AutoCorect
I had sent you a sample file over email...

Posted: Wed Jul 30, 2008 4:34 pm
by proxy3d
Add, before to call SetRVMargins:

Code: Select all

srve. RichViewEdit. RVData. State: = srve. RichViewEdit. RVData. State + [rvstSkipFormatting];
and After call SetRVMargins:

Code: Select all

srve. RichViewEdit. RVData. State: = srve. RichViewEdit. RVData. State - [rvstSkipFormatting];

Posted: Wed Jul 30, 2008 5:06 pm
by AutoCorect
Thank you.
It's loading faster.
But there is a problem: if I load again the same rtf the text is shifted down and to the right.
Also I have only one page of text available.
Here are some screen captures:
http://fileserver7.jpghosting.com/image ... ce2fc9.PNG
http://fileserver7.jpghosting.com/image ... 88cfd1.PNG
http://fileserver7.jpghosting.com/image ... dbb040.PNG

If I deactivate those 2 lines of code, all returns to normal.
Any ideas on how to solve this?

Thanks again.

Later edit: in ActionTest demo if I modify it like this:

Code: Select all

procedure TForm3.RVAControlPanel1MarginsChanged(Sender: TrvAction;
  Edit: TCustomRichViewEdit);
begin
  SRichViewEdit1.RichViewEdit.RVData.State := SRichViewEdit1.RichViewEdit.RVData.State + [rvstSkipFormatting];
  SRichViewEdit1.SetRVMargins;
  SRichViewEdit1.RichViewEdit.RVData.State := SRichViewEdit1.RichViewEdit.RVData.State - [rvstSkipFormatting];
...
end;
Then it does the same problem.

Posted: Thu Jul 31, 2008 8:17 pm
by proxy3d

Code: Select all

procedure TForm3.RVAControlPanel1MarginsChanged(Sender: TrvAction; 
  Edit: TCustomRichViewEdit); 
begin 
  SRichViewEdit1.RichViewEdit.RVData.State := SRichViewEdit1.RichViewEdit.RVData.State + [rvstSkipFormatting]; 
  SRichViewEdit1.SetRVMargins; 
  SRichViewEdit1.RichViewEdit.RVData.State := SRichViewEdit1.RichViewEdit.RVData.State - [rvstSkipFormatting]; 
  SRichViewEdit1.RichViewEdit.Format;
  SRichViewEdit1.calculatePageCount;
... 
end;

Posted: Thu Jul 31, 2008 9:57 pm
by AutoCorect
The text is not shifted anymore but I still have just one page to edit.
If I press PageDown a couple of times then srve.CurrentPage is updated normally but I still see only the first page.
Only if I resize the main window or if I run SclRVRuler1.DoMarginChanged returns to normal.
But in both cases few secondes are needed.
Strange, this happens in ActionTest only when the main window is maximized, but in my program it happens for any window state/size.

Posted: Mon Aug 18, 2008 8:25 am
by AutoCorect
I found situations when if I load a different rtf after the first I get the same error: only one page to edit.
What should I do?
Thank you for your reply.

Posted: Mon Aug 18, 2008 12:50 pm
by proxy3d
How I can reproduce this error?

Posted: Mon Aug 18, 2008 3:16 pm
by AutoCorect
In your ActionTest demo load again "readme.rvf". After that you'll have only one page.
If you resize the main window it returns to normal.
If this doesn't work I will send you the modified demo.

Posted: Mon Aug 25, 2008 7:18 am
by AutoCorect
Have you try it...?

Posted: Thu Aug 28, 2008 1:34 pm
by AutoCorect
:( You forgot about my problem. Please give me some solution for this problem.

Thanks, I still wait your solution

Posted: Thu Aug 28, 2008 4:13 pm
by proxy3d
Sorry, I thought that have corrected этото a bug. Tomorrow I will correct this bug.

Posted: Thu Aug 28, 2008 4:45 pm
by proxy3d
replace code in ActionTest:

Code: Select all

procedure TForm3.RVAControlPanel1MarginsChanged(Sender: TrvAction; Edit: TCustomRichViewEdit);
begin
  SRichViewEdit1.RichViewEdit.RVData.State :=
    SRichViewEdit1.RichViewEdit.RVData.State + [rvstSkipFormatting];
  SRichViewEdit1.SetRVMargins;
  SRichViewEdit1.RichViewEdit.Modified := False;

  case SRichViewEdit1.ViewProperty.ZoomMode of
    rvzmPageWidth:
      ListZoom.ItemIndex := ListZoom.Items.IndexOf('PageWidth');
    rvzmFullPage:
      ListZoom.ItemIndex := ListZoom.Items.IndexOf('FullPage');
    rvzmCustom:
      ListZoom.ItemIndex := ListZoom.Items.IndexOf(
        IntToStr(Round(SRichViewEdit1.ViewProperty.ZoomPercent)));
  end;

  if SRichViewEdit1.PageProperty.FormatMode = srvfmA0 then
    ListFormat.ItemIndex := ListFormat.Items.IndexOf('A0')
  else if SRichViewEdit1.PageProperty.FormatMode = srvfmA1 then
    ListFormat.ItemIndex := ListFormat.Items.IndexOf('A1')
  else if SRichViewEdit1.PageProperty.FormatMode = srvfmA2 then
    ListFormat.ItemIndex := ListFormat.Items.IndexOf('A2')
  else if SRichViewEdit1.PageProperty.FormatMode = srvfmA3 then
    ListFormat.ItemIndex := ListFormat.Items.IndexOf('A3')
  else if SRichViewEdit1.PageProperty.FormatMode = srvfmA4 then
    ListFormat.ItemIndex := ListFormat.Items.IndexOf('A4')
  else if SRichViewEdit1.PageProperty.FormatMode = srvfmA5 then
    ListFormat.ItemIndex := ListFormat.Items.IndexOf('A5')
  else if SRichViewEdit1.PageProperty.FormatMode = srvfmA6 then
    ListFormat.ItemIndex := ListFormat.Items.IndexOf('A6')
  else if SRichViewEdit1.PageProperty.FormatMode = srvfmLetter then
    ListFormat.ItemIndex := ListFormat.Items.IndexOf('Letter')
  else if SRichViewEdit1.PageProperty.FormatMode = srvfmLegal then
    ListFormat.ItemIndex := ListFormat.Items.IndexOf('Legal');

  ListFormat.ItemIndex :=
    ListFormat.Items.IndexOf(GetPaperFormatName(SRichViewEdit1.PageProperty.FormatMode));

  ListUnits.ItemIndex :=
    ListUnits.Items.IndexOf(GetUnitsName(SRichViewEdit1.UnitsProgram));

  SclRVRuler1.UnitsDisplay := TRulerUnits(SRichViewEdit1.UnitsProgram);
  SclRVRuler2.UnitsDisplay := TRulerUnits(SRichViewEdit1.UnitsProgram);
  SRichViewEdit1.RichViewEdit.RVData.State :=
     SRichViewEdit1.RichViewEdit.RVData.State - [rvstSkipFormatting];
  
  //////////          Adding       ////////////
  SRichViewEdit1.RefreshData; 
  ///////////////////////////////////////////
end;

Posted: Fri Aug 29, 2008 7:37 am
by AutoCorect
Thank you.
It's an improvment in speed.
Maybe in the future versions you will increase loading speed and also you will link RefreshData procedure to OnProgress event. Even after the progressbar shows 100% the user waits so the document become available to edit. For example in my tests half of the loading time is taken by RefreshData...