Page 1 of 1

transparent background

Posted: Thu Sep 13, 2012 4:48 am
by dave novo
Hello,

We use DrawPage to render the ScaleRichView to a canvas. But we do not want to have a background to the ScaleRichView.

We have tracked down the code to here. If you comment out the lines and add what we added, you can get a transparent background. Of course, you can add a special property to the page properties use that to make the background transparent as well, we just wanted to make minimal changes.

We can modify the code of course, but prefer to make whatever modification locally that will makes it into the release branch.

function TSRichViewEdit.DrawPageBG(Canvas: TCanvas;
PageRect, PaintRect: TRect;
ScaleX, ScaleY: Single;
OffsetX, OffsetY, PageNo: Integer; Printing, UseWordPainters: Boolean): Boolean;
var
PgW, PgH, PictWidth, PictHeight, SPictWidth, SPictHeight : Integer;
indexX, indexY, OffX, OffY: Integer;
BGImage: TBitmap;
OldRect : TRect;
hRegion: HRGN;

procedure FillBG;
begin
If FBackgroundProperty.FGlobalPageBackgroundColor = clNone then
// Removed this min->white
// Canvas.Brush.Color := min(SRVGetSysColor(FRichViewEdit.Color), $0FFFFFF)
Canvas.Brush.Color := SRVGetSysColor(FRichViewEdit.Color)
Else
Canvas.Brush.Color := SRVGetSysColor(FBackgroundProperty.FGlobalPageBackgroundColor);

// Added this if
if Canvas.Brush.Color <> clNone then
Canvas.FillRect(PaintRect);
end;

Posted: Thu Sep 13, 2012 12:44 pm
by Sergey Tkachenko
Accepted (with some correction: when called to draw TSRichViewEdit itself, clWhite will be used instead of clNone)

Posted: Thu Sep 13, 2012 6:20 pm
by dave novo
Hi Sergey,

Can you paste in the actual code you will use. We will then copy that to our local version.

Posted: Thu Sep 13, 2012 6:49 pm
by Sergey Tkachenko
You can update your version - this change is included in SRV 4.8.

Posted: Thu Sep 13, 2012 7:16 pm
by dave novo
Hi Sergey,

Just wondering what your "correction" is going to be. You wrote
with some correction:

Posted: Thu Sep 13, 2012 7:25 pm
by Sergey Tkachenko
Parameter AllowTransparency in DrawPageBG. True when called from DrawPage, False when called to draw the component itself.
If False, clNone is painted as clWhite.