Document Background Color

General TRichView support forum. Please post your questions here
Post Reply
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Document Background Color

Post by standay »

Hi Sergey,

This is probably real simple but I can NOT figure out how to save and load an rvf file with background color intact using a regular rve. How do you do it? I have the rve.style.color set, I've tried enabling rvfoSaveBack and rvfoLoadBack, but no matter what I do, when I open the file I save from my app in your RichViewActionsTest demo, the background is white (should be a dark gray). Individual paragraphs or text retain their back colors (if I set them) but never the whole document color. I want the whole doc background color to be saved and loaded. Your demo app does exactly what I want when I click the Format|Background Color menu. I'm not using actions so I need to know how to do this manually.

Also, I have my source rve.VAlign set to tlCenter, and I want that saved and loaded when I open the file in another rve editor as well. I have not figured out how to do that either.

Thanks Sergey

Stan
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Re: Document Background Color

Post by standay »

Hi Sergey,

OK, this seemed to work when saving my file:

Code: Select all

  TCustomRichView(coverRVE).Color := CoverRVEStyle.Color;
This worked too:

Code: Select all

  coverRVE.SetIntProperty( rvipColor , CoverRVEStyle.Color );
I'd guess the 2nd way is the one to use.

This also helped with scooting things down some in the saved file:

Code: Select all

  coverRVE.SetIntProperty( rvipTopMargin , 150 );
But I would still like to get the document's vertical alignment set to center when the file is saved, so if you can tell me about that I would appreciate it. This rve always has just 1 image and a few lines of text below that image. Text and image are all aligned center horizontally and vertically, and I'd like to be able to save the file that way.

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

Re: Document Background Color

Post by Sergey Tkachenko »

rv.Style.Color is not saved in RVF, only rv.Color
(rv.Style.Color is used only if rv.Color = clNone).

Assigning the property directly or via SetIntProperty, it does not matter, so SetIntProperty does not add any new functionality.
(a useful method is SetIntPropertyEd that allows assigning properties as an undoable operation).

Currently, VAlign is not saved in RVF.
You can store additional information in RVF using DocProperties or DocObjects property.
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Re: Document Background Color

Post by standay »

Thanks Sergey, that's good enough and lets me know what I need to continue.

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

Re: Document Background Color

Post by Sergey Tkachenko »

If you want to store VAlign in RVF, include rvfoSaveDocProperties and rvfoLoadDocProperties in RVFOptions.
Before saving, call

Code: Select all

rv.DocProperties.Values['VAlign'] := IntToStr(ord(rv.VAlign));
After loading, call

Code: Select all

rv.VAlign := TTextLayout(StrToIntDef(rv.DocProperties.Values['VAlign'], 0));
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Re: Document Background Color

Post by standay »

Thanks Sergey

Stan
Post Reply