Interface is frozen when loading a big file
-
- Posts: 84
- Joined: Sun Dec 16, 2007 7:15 pm
Interface is frozen when loading a big file
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.
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.
-
- Posts: 84
- Joined: Sun Dec 16, 2007 7:15 pm
Add, before to call SetRVMargins:
and After call SetRVMargins:
Code: Select all
srve. RichViewEdit. RVData. State: = srve. RichViewEdit. RVData. State + [rvstSkipFormatting];
Code: Select all
srve. RichViewEdit. RVData. State: = srve. RichViewEdit. RVData. State - [rvstSkipFormatting];
-
- Posts: 84
- Joined: Sun Dec 16, 2007 7:15 pm
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:
Then it does the same problem.
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;
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;
-
- Posts: 84
- Joined: Sun Dec 16, 2007 7:15 pm
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.
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.
-
- Posts: 84
- Joined: Sun Dec 16, 2007 7:15 pm
-
- Posts: 84
- Joined: Sun Dec 16, 2007 7:15 pm
-
- Posts: 84
- Joined: Sun Dec 16, 2007 7:15 pm
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;
-
- Posts: 84
- Joined: Sun Dec 16, 2007 7:15 pm
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...
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...