Interface is frozen when loading a big file

ScaleRichView support and discussion (TRichView add-on for WYSIWYG editing)
AutoCorect
Posts: 84
Joined: Sun Dec 16, 2007 7:15 pm

Interface is frozen when loading a big file

Post 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.
proxy3d
ScaleRichView Developer
Posts: 307
Joined: Mon Aug 07, 2006 9:37 am

Post 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?
AutoCorect
Posts: 84
Joined: Sun Dec 16, 2007 7:15 pm

Post by AutoCorect »

I had sent you a sample file over email...
proxy3d
ScaleRichView Developer
Posts: 307
Joined: Mon Aug 07, 2006 9:37 am

Post 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];
AutoCorect
Posts: 84
Joined: Sun Dec 16, 2007 7:15 pm

Post 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.
proxy3d
ScaleRichView Developer
Posts: 307
Joined: Mon Aug 07, 2006 9:37 am

Post 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;
AutoCorect
Posts: 84
Joined: Sun Dec 16, 2007 7:15 pm

Post 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.
AutoCorect
Posts: 84
Joined: Sun Dec 16, 2007 7:15 pm

Post 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.
proxy3d
ScaleRichView Developer
Posts: 307
Joined: Mon Aug 07, 2006 9:37 am

Post by proxy3d »

How I can reproduce this error?
AutoCorect
Posts: 84
Joined: Sun Dec 16, 2007 7:15 pm

Post 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.
AutoCorect
Posts: 84
Joined: Sun Dec 16, 2007 7:15 pm

Post by AutoCorect »

Have you try it...?
AutoCorect
Posts: 84
Joined: Sun Dec 16, 2007 7:15 pm

Post by AutoCorect »

:( You forgot about my problem. Please give me some solution for this problem.

Thanks, I still wait your solution
proxy3d
ScaleRichView Developer
Posts: 307
Joined: Mon Aug 07, 2006 9:37 am

Post by proxy3d »

Sorry, I thought that have corrected этото a bug. Tomorrow I will correct this bug.
proxy3d
ScaleRichView Developer
Posts: 307
Joined: Mon Aug 07, 2006 9:37 am

Post 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;
AutoCorect
Posts: 84
Joined: Sun Dec 16, 2007 7:15 pm

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