How to add/ delete bookmarks or checkpoints (user defined)

General TRichView support forum. Please post your questions here
Nostradamus
Posts: 67
Joined: Sat May 13, 2006 1:56 pm
Location: Australia

How to add/ delete bookmarks or checkpoints (user defined)

Post by Nostradamus »

Hi,

I would like to
add/ delete bookmarks or checkpoints (user defined) to a form which opens
unicode text/rtf document or ebook.

So if I used text to speech to read a document user can keep a record of where they got to or are up to in the text.

Also, if reader is actually reading something they can keep a record of where they are if they close the program and reopen it later.
Sergey Tkachenko
Site Admin
Posts: 17310
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

If you only needs to store a position, you can store the value of FirstItemVisible. After opening, get coordinates of this item (GetItemCoords) and scroll to it (ScrollTo).

If you want to work with checkpoints in TRichViewEdit, you can use the methods: InsertCheckpoint, RemoveCheckpointAtCaret, GetCheckpointAtCaret.
(alternatively, you can use SetCurrentCheckpointInfo, RemoveCurrentCheckpoint, GetCurrentCheckpoint, but the first group of methods is better)

If you want to work with checkpoints in TRichView, use AddNamedCheckpoint and RemoveCheckpoint.

See http://www.trichview.com/help/checkpoints_overview.html
Nostradamus
Posts: 67
Joined: Sat May 13, 2006 1:56 pm
Location: Australia

Demo project which shows this feature ?

Post by Nostradamus »

I am a person with more ideas than time....
It would be much appreciated if there was a demo project to study.

thanks

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

Post by Sergey Tkachenko »

See Editors\Editor 1\ demo.
It allows adding, editing and deleting checkpoints. Menu Edit | Checkpoint, or a context menu.
This demo uses SetCurrentCheckpointInfo, RemoveCurrentCheckpoint, GetCurrentCheckpoint method. I recommend to change them to InsertCheckpoint, RemoveCheckpointAtCaret, GetCheckpointAtCaret.
Nostradamus
Posts: 67
Joined: Sat May 13, 2006 1:56 pm
Location: Australia

OK, where is help for how to use InsertCheckpoint ?

Post by Nostradamus »

I looked at the demo.

I am confused about what to do......
I can see that I can add a menu item called InsertCheckpoint, but that is all I don't know what code to add to the onclick event because there is no demo.

I looked at help and now
I am still confused....

Can I please see a working demo.
Sergey Tkachenko
Site Admin
Posts: 17310
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Do you have problems locating the source code of this demo?
For the trial version, source code of demos is in "Demo" folder of
http://www.trichview.com/rvfiles/rvhelp.zip
Open the appropriate subfolder of this "Demo" folder
("Delphi" contains demos for Delphi 4-2007, "DelphiUnicode" for Delphi 2009-2010, "CBuilder" for C++Builder 6-2007, "CBuilderUnicode" for C++Builder 2009-2010). In this subfolder, you can find the source code of this demo in "Editors\Editor 1" directory.
In this demo, open Unit1.pas (or Unit1.cpp for C++Builder), and find
procedure TForm1.mitEditCheckpointClick.
This procedure contains code for working this checkpoints.
Nostradamus
Posts: 67
Joined: Sat May 13, 2006 1:56 pm
Location: Australia

NOW I see what you are talking about

Post by Nostradamus »

first you have to go to the 'Edit' menu and go down to item 'checkpoint' and click it.

Then you have the option to add a checkpoint.
BEFORE CLICKING 'ADD' BUTTON YOU CAN
A)MOVE THE CURSOR TO THE POINT IN THE TEXT YOU WISH TO BOOKMARK

B) THEN GIVE THE BOOKMARK A NAME.

Then if you go to the 'Misc' Menu and go down and click 'Go to checkpoint'
you can select the checkpoint you want to move to.

Many thanks Sergey !

I am not confused anymore.
Nostradamus
Posts: 67
Joined: Sat May 13, 2006 1:56 pm
Location: Australia

I found another problem with 'go to checkpoint'

Post by Nostradamus »

Hi,

I just noticed if I turn the project off and restart it the saved checkpoints I added are missing.

How do I get the project/program to retain newly saved checkpoints even if the program is turned off and then restarted.
Sergey Tkachenko
Site Admin
Posts: 17310
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Checkpoints are saved in RVF and RTF files.
If you save a file, then load it, and checkpoints are missing, please create a simple project to reproduce this problem.
Nostradamus
Posts: 67
Joined: Sat May 13, 2006 1:56 pm
Location: Australia

I USED THE EDITOR 1 DEMO

Post by Nostradamus »

Hi Sergey,

I got this result using the Editor 1 demo..
C:\Program Files\Embarcadero\RAD Studio\7.0\lib\1-TRichView\Demos\DelphiUnicode\Editors\Editor 1

I WAS WONDERING IF AN INI FILE WOULD NEED TO BE CREATED TO SAVE/LOAD THE CHECKPOINTS ?
Sergey Tkachenko
Site Admin
Posts: 17310
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

No, checkpoints are saved directly in RVF/RTF file, additional INI files are not required.
May be you did not save a modified file?
I just tried - added a new checkpoint, then saved the file as RVF (File | Save & Export), then loaded this file (File | Load & Import), and the new checkpoint was loaded.

This demo does not autosave files, and it does not ask to save a modified file. It only saves and loads when you run the commands of menu "File".

If you need to implement the standard New, Open, Save, Save As commands and prompt to save a modified document on exit, see the "Editor 2" demo. Or use RichViewActions.
Nostradamus
Posts: 67
Joined: Sat May 13, 2006 1:56 pm
Location: Australia

Another new problem...

Post by Nostradamus »

OK I get or understand that I must first save the file before closing the program now, But now I get 2 new problems.

First I select the word Control then copy..
To set a checkpoint I go to menu...
Edit >>> Checkpoint
I paste the clipboard memory word "Control" into the
Name window
I enter "1" as the tag number then I click 'add'

I then goto menu
'Misc' >>> 'Go to Checkpoint'
I see the newly added checkpoint in the window.
I select the 'controls' checkpoint
then I click 'go to' button and this works fine.

If I save/export to the readme.rvf file with the new checkpoint/s
it prompts me to replace it.
I select yes.

I close the program.

I re-open the program.
If I then goto menu
'Misc' >>> 'Go to Checkpoint'

The newly added checkpoints are not there ! But they should be.

Also, if I try to Load & Import any saved RVF file I get error message
"Error during Loading"
Nostradamus
Posts: 67
Joined: Sat May 13, 2006 1:56 pm
Location: Australia

I have noticed a similar problem with Editor2 .. It does not

Post by Nostradamus »

When I try to save files with Editor 2 they do not save correctly.

When I save an open RVF file in Editor 2 with a new name and then open the
the new file after re-opening the original file the new file seems to be truncated or shortened.

Any help is always appreciated
Sergey Tkachenko
Site Admin
Posts: 17310
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I received your demo.
Are you sure that you saved README.RVF in the directory of this demo, not in another directory?
In your zip file, README.RVF is modifed in 2003.

As for "Editor 2" demo, probably it stops loading on controls inserted in document. In order to load controls from RVF file, these controls must be registered.
Add in the "Editor 2" demo the following code (to the end of Unit1.pas, before the final "end."):

Code: Select all

initialization
  // We need to register classes in order to load them from rvf files
  RegisterClasses([TButton, TEdit, TOleContainer]);
Nostradamus
Posts: 67
Joined: Sat May 13, 2006 1:56 pm
Location: Australia

Same Directory... still same problem

Post by Nostradamus »

I notice when it compiles it takes an inordinately long time.
I will email the error messages for both Editor 1 and Editor after compiling under Delphi 2010. Called Editor 1.txt and Editor2.txt.

I tried adding a modified version of your code snippet to Editor2 Project....
initialization
// We need to register classes in order to load them from rvf files
RegisterClasses([TButton, TEdit]);

olecontainer was not declared and stopped it from working so I deleted it.

The problem which happens is that the load & import once I clicked it produces error message "Error during loading" and the truncated/ shortened file
stops always at this term "a2" where the 2 is supertext.

If I save to the same file name and replace it (readme.rvf), it prompts me to replace it and I click 'yes'. While the Editor is still open/on I then attempt to reopen the same readme.rvf file and I get the truncated version (but the saved addition I added before saving " This was edited 22032010" is still there) and the error message "Error during loading" again stopping at this term "a2" where the 2 is supertext.

If, however, I try closing Editor 1 and double clicking the readme.rvf file
the file opens normally showing the whole file contents, but the saved text I added before saving is no longer there.
It's as if the Load & Import button only loaded a temporary file.

This is strange behaviour.
Post Reply