time passed until first typed letter appeared in memo.

General TRichView support forum. Please post your questions here
Post Reply
j&b
Posts: 173
Joined: Mon Sep 05, 2005 1:35 pm

time passed until first typed letter appeared in memo.

Post by j&b » Sat Apr 07, 2018 4:28 pm

I have copied more and more pictures over time into a TRichView-Memo. Some day I noticed that more and more time passed until first typed letter appeared in memo.
Following typed letter immediately appeared. Cause are the many pictures.

1. Can you solve this problem so that letter 'immediately' appears (as usual)

j&b
Posts: 173
Joined: Mon Sep 05, 2005 1:35 pm

Re: time passed until first typed letter appeared in memo.

Post by j&b » Sat Apr 07, 2018 4:30 pm

I've forgotten:

2. How can I know how many bytes occupy a memo (with pictures

Sergey Tkachenko
Site Admin
Posts: 14078
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: time passed until first typed letter appeared in memo.

Post by Sergey Tkachenko » Sat Apr 07, 2018 7:37 pm

How can I reproduce this problem?

j&b
Posts: 173
Joined: Mon Sep 05, 2005 1:35 pm

Re: time passed until first typed letter appeared in memo.

Post by j&b » Sun Apr 08, 2018 7:51 am

Hello Sergey,

you copy many pictures into a TRichView memo. How many do you have to try.
Then you change the record and return to the memo (with the many pictures) and write a word in the memo. Although you have already pressed some letters, the first letter of the word appears only after a short time.

Through my solution Cursor appears after a short time. Then you can write a word without the described effect.



My solution:

I add 4 lines at the end of memo.Enter.
They cause that the pressed letter appears immediately as soon as the cursor appears in memo.

I would like to use these 2 lines only if the memo exceeds a certain size ('memo.size')


procedure TForm1.memoEnter(Sender: TObject);
begin
...
if memo.size>xyz then begin
RVSetLinearCaretPos(memo,0);
memo.InsertText('',false);

end;
end;

Does someone know a better solution?

Sergey Tkachenko
Site Admin
Posts: 14078
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: time passed until first typed letter appeared in memo.

Post by Sergey Tkachenko » Sun Apr 08, 2018 10:25 am

For testing, try to increase side of image cache.

Add in DPR file, before creating any form:

uses RVGrCache;

RichViewMaxPictureCount := 10000; // set value greater than the count of pictures in your document

j&b
Posts: 173
Joined: Mon Sep 05, 2005 1:35 pm

Re: time passed until first typed letter appeared in memo.

Post by j&b » Mon Apr 09, 2018 6:43 am

Your hint wasn'tsuccessful. Everything as usual.

Here my .dpr:

program mHilfe;

uses
Forms,
unit1_mh in 'unit1_mh.pas' {Form1},
RVGrCache;



{$R *.RES}

begin
RichViewMaxPictureCount := 100000;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

By the way Is there a function to know the actual (tatsächliche) size of a memo.

Sergey Tkachenko
Site Admin
Posts: 14078
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: time passed until first typed letter appeared in memo.

Post by Sergey Tkachenko » Mon Apr 09, 2018 10:43 am

Does the same problem happen in ActionTest project, or only in your project?

Unfortunately, there are no function that return the amount of memory used by the editor. The editor allocates many objects, and nobody calculates their total size. Moreover, because of image caching, the amount of allocated memory may change even on scrolling (because some images are activated, some are deactivated).

j&b
Posts: 173
Joined: Mon Sep 05, 2005 1:35 pm

Re: time passed until first typed letter appeared in memo.

Post by j&b » Mon Apr 09, 2018 11:34 am

In other words, you can't do anything against the delay until first letter appears ?

Sergey Tkachenko
Site Admin
Posts: 14078
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: time passed until first typed letter appeared in memo.

Post by Sergey Tkachenko » Mon Apr 09, 2018 12:50 pm

I still do not understand why it may happen.
Are these image resized?
Also, I which graphic classe is used for them? May be you send me RVF file containing some reasonable count of images, I'll multiply them for testing.

And this delay may be caused by your code in events, what's why I ask about reproducing it in an unmodified ActionTest demo.

j&b
Posts: 173
Joined: Mon Sep 05, 2005 1:35 pm

Re: time passed until first typed letter appeared in memo.

Post by j&b » Tue Apr 10, 2018 7:36 am

Trials confirmed the assumption that the number of images in the memo is responsible for the delay.

procedure TForm1.MemoEnter (Sender: TObject);
var i, picZae: integer;
begin
   // ...

   for i: = 0 to Memo.ItemCount-1 do
     if Memo.GetItemStyle (i) = rvsPicture then inc (picZae);
   pStatusbar.Caption: = 'Number of images:' + intToStr (picZae);
   if picZae> 10 then memo.InsertText ('', false);

end;

Is there a better solution than the line in the procedure TForm1.MemoEnter ?

Sergey Tkachenko
Site Admin
Posts: 14078
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: time passed until first typed letter appeared in memo.

Post by Sergey Tkachenko » Tue Apr 10, 2018 7:47 am

I received your file and I need some time to test it.

Sergey Tkachenko
Site Admin
Posts: 14078
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: time passed until first typed letter appeared in memo.

Post by Sergey Tkachenko » Wed Apr 11, 2018 11:20 am

You use TDBRichViewEdit.
It does some work when the table is moved to an editng state (it stores the field content in a stream, to check later, if it was really changed).
The editor moves database into editing state when you type a character or call any editing method (such as InsertText).

So, when you call InsertText, this processing occurs immediately, without waiting for user actions.

Sorry, it is unavoidable. The only alternative solution is using TRichViewEdit instead of TDBRichViewEdit: load data from field to the editor, start editing, then save modified document to database.

j&b
Posts: 173
Joined: Mon Sep 05, 2005 1:35 pm

Re: time passed until first typed letter appeared in memo.

Post by j&b » Thu Apr 12, 2018 10:40 am

Thank you for your efforts.

I will try my solution.
So that not every record-change determines the number of images, I have added a button to allow to count images or not
Only in a few memos are a large number of pictures.

Jürgen


procedure TForm1.memoEnter(Sender: TObject);
var i,picZae: integer;
begin
...
if fMemoVerzoegerung= true then begin //Schalter ja/nein
for i := 0 to Memo.ItemCount-1 do
if Memo.GetItemStyle(i)=rvsPicture then inc(picZae);
if picZae>10 then memo.InsertText('',false);
end;

Post Reply