addpicture, with filename

General TRichView support forum. Please post your questions here
Post Reply
Stef
Posts: 90
Joined: Mon Aug 29, 2005 9:56 am
Contact:

addpicture, with filename

Post by Stef »

hi Sergey,

I'm still struggling with conversion of programs build on old versions of RV to the new(er) version.

I want to ADD a picture in a RVE and assign a filename (used in html-export) to it.

I use AddPictureEx(Name, ....
now I suppossed that Name is the filename,
the help file says nothing about this parameter,
until you look at "Building RichView Document",
where is stated "name of picture; this string is not used by RichView itself"

So I use method 1

Code: Select all

    RVE.AddPictureEx(line,gr,-1,rvvaBaseLine);
                          RVE.SetCurrentItemExtraStrProperty(rvespImageFileName,line,false);
but sometimes this gives an string index out of bounds,

so therefor I use method 2

Code: Select all

    RVE.AddPictureEx(line,gr,-1,rvvaBaseLine);
    RVE.Format;
        RVE.SetItemExtraStrProperty(RVEx.ItemCount-1,rvespImageFileName,line);

What code is correct ?

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

Post by Sergey Tkachenko »

As you noticed, there are 2 places where you can store file names:
1) Item name (the first parameter of AddPictureEx, see also GetItemText and SetItemText).
2) Special property.

Item names can be used for any purpose, you can store image file names (or any other one line info) there if you need. But special support is provided only for file names in the special property (for example, HTML export can use these file names, if the proper option is included in the Options of SaveHTML/SaveHTMLEx)

The first code is incorrect because SetCurrentItemExtraStrProperty works with the item at the position of caret in the FORMATTED document (see the remark about editing-style methods in the help file). The document is unformatted after AddPictureEx (until you call Format), so the caret position is undefined and you cannot use this method.

The second code is correct, but Format is not required there, SetItemExtraStrProperty can be called for unformatted documents (see the remark about viewer-style methods in the help file). It's a good practice to use only viewer-style methods for document generation, and call Format only one time - when the generation is complete.
Calling Format many times is harmless, but this is the slowest method, so unnecessary calls slows the application down.
Stef
Posts: 90
Joined: Mon Aug 29, 2005 9:56 am
Contact:

Post by Stef »

Sergey,

thanks very much for the clear explanation.
Post Reply