Page 1 of 1

time passed until first typed letter appeared in memo.

Posted: Sat Apr 07, 2018 4:28 pm
by j&b
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)

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

Posted: Sat Apr 07, 2018 4:30 pm
by j&b
I've forgotten:

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

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

Posted: Sat Apr 07, 2018 7:37 pm
by Sergey Tkachenko
How can I reproduce this problem?

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

Posted: Sun Apr 08, 2018 7:51 am
by j&b
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?

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

Posted: Sun Apr 08, 2018 10:25 am
by Sergey Tkachenko
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

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

Posted: Mon Apr 09, 2018 6:43 am
by j&b
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.

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

Posted: Mon Apr 09, 2018 10:43 am
by Sergey Tkachenko
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).

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

Posted: Mon Apr 09, 2018 11:34 am
by j&b
In other words, you can't do anything against the delay until first letter appears ?

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

Posted: Mon Apr 09, 2018 12:50 pm
by Sergey Tkachenko
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.

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

Posted: Tue Apr 10, 2018 7:36 am
by j&b
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 ?

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

Posted: Tue Apr 10, 2018 7:47 am
by Sergey Tkachenko
I received your file and I need some time to test it.

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

Posted: Wed Apr 11, 2018 11:20 am
by Sergey Tkachenko
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.

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

Posted: Thu Apr 12, 2018 10:40 am
by j&b
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;