Page 1 of 1

Persistent background image in TDBRichviewedit

Posted: Wed Mar 28, 2012 8:28 pm
by msimmons15
I have a form using a TDBRichviewedit. One (and only one) of the dataset records tied to this control contains text using a backgroundimage. That image properly displays when I scroll to that record.

The problem is that the background image remains in place as I scroll to different dataset records that do not have the background image. What is the best way to "clear" this image? Is there an option I'm missing?

Thanks,
Mike Simmons

Posted: Thu Mar 29, 2012 8:47 am
by Sergey Tkachenko
There are fields formats that can store or cannot store a background image.

Currently, the only format that can store it is RVF (if rvfoSaveBack and rvfoLoadBack are included in DBRichViewEdit.RVFOptions).

For formats that cannot store a background image, it is assumed that an image is the editor decoration, it is displayed for all records. If you want to store it in the record, you need to store it somewhere outside, and assign to BackgroundBitmap in DBRichViewEdit.OnLoadDocument, clear it in DBRichViewEdit.OnNewDocument.

As for RVF that can store an image together with the document, the behavior of TDBRichViewEdit is different in TRichView v13.8 (available for registered users) and older versions of TRichView.
Older versions: do nothing special with the background image, so you need to clear it (assign nil to DBRichViewEdit.BackgroundBitmap) in DBRichViewEdit.OnNewDocument.
New version: clears the bitmap automatically when necessary, no additional code is required.
Note: to assign a background bitmap that will be saved in RVF, you need a code like this:

Code: Select all

if DBRichViewEdit1.CanChange then begin
  DBRichViewEdit1.BackgroundBitmap := ...
  DBRichViewEdit1.Change;
end;

Posted: Thu Mar 29, 2012 11:05 pm
by msimmons15
Thanks for the explanation and solution. I was using RVF and that handled it!

Mike Simmons