RichViewEdit and WIndows Textscaling

General TRichView support forum. Please post your questions here
Post Reply
WLemmermeyer
Posts: 11
Joined: Fri Jun 06, 2014 5:32 am
Location: Germany

RichViewEdit and WIndows Textscaling

Post by WLemmermeyer »

Helllo,

I use TRichView 18.

If I set windows scaling from 100 to 150 the size of the text inside the TRichview is scaled. My problem: I use TRVReportHelper to print the content with FastReport. It works fine - but if I change the WIndows scaling, the fontsize scales, too - and this is bad. How can I change this behaviour?

In help I found this:
https://www.trichview.com/help/idh_tric ... rinch.html

but has no effect... Any hints?

Best regards
Wolfgang
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: RichViewEdit and WIndows Textscaling

Post by Sergey Tkachenko »

DocumentPixelsPerInch does not work for TRVReportHelper, its only for TRichView and TRichViewEdit.

Unfortunately, the current version of the components does not allow to define a DPI of the target Canvas, it always uses the actual Canvas DPI. So, for screen canvas, it is always the screen DPI.
(although it's not difficult to add this feature, it is already implemented in ReportBuilder wrapper in a component inherited from TRVRepoertHelper; probably, I'll add this feature in future).

I can suggest an alternative solution. Instead of TRVReportHelper, you can use TRVPrint with VirtualPrinter.Active = True.
In this mode, you can define desired DPI in RVPrint.VirtualPrinter.PixelsPerInchX and Y properties. You can assign all RVPrint.Margins = 0 to make the result look like in TRVReportHelper. The only problem, TRVPrint does not store a document, so you need to store it somewhere else.
WLemmermeyer
Posts: 11
Joined: Fri Jun 06, 2014 5:32 am
Location: Germany

Re: RichViewEdit and WIndows Textscaling

Post by WLemmermeyer »

Sergey Tkachenko wrote: Thu Jul 16, 2020 12:05 pm (although it's not difficult to add this feature, it is already implemented in ReportBuilder wrapper in a component inherited from TRVRepoertHelper; probably, I'll add this feature in future).
where can I find this wrapper? Maybe I can apply this part of code in my FastReport Wrapper - I need to print more data in this report than the rtf....
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: RichViewEdit and WIndows Textscaling

Post by Sergey Tkachenko »

In <TRichView Dir>\ThirdParty\ReportBuilder\Source\ppRichView.pas

It is TRVReportHelperRef that has internal TRichView of TReportRichViewRef class that has RVData of TReportRVDataRef class.
TRVReportHelperRef has several additional features, for example it can store documents in DFM (or, in this case, in reports).
But the most interesting is TReportRVDataRef.GetSADForFormatting method that overrides the target DPI by the value specified in FInternalPixelsPerInch.
WLemmermeyer
Posts: 11
Joined: Fri Jun 06, 2014 5:32 am
Location: Germany

Re: RichViewEdit and WIndows Textscaling

Post by WLemmermeyer »

Thanks.

I convert the relevant code to my component:

Code: Select all

{ TRVReportHelperFR }

function TRVReportHelperFR.CreateRichView: TCustomPrintableRV;
begin
  Result := TReportRichViewFR.Create(Self);
end;

{ TReportRichViewFR }

constructor TReportRichViewFR.Create(AOwner: TComponent);
begin
  inherited;
  FInternalPixelsPerInch := 72;
end;

function TReportRichViewFR.GetDataClass: TRichViewRVDataClass;
begin
  Result := TReportRVDataRef;
end;

{ TReportRVDataRef }

procedure TReportRVDataRef.GetSADForFormatting(Canvas: TCanvas; out sad: TRVScreenAndDevice);
var
  ppi: Integer;
begin
  inherited;
  ppi := TReportRichViewFR(RichView).FInternalPixelsPerInch;
  if ppi > 0 then
  begin
    PrnSad.ppixDevice := ppi;
    PrnSad.ppiyDevice := ppi;
    sad.ppixDevice := ppi;
    sad.ppiyDevice := ppi;
  end;
end;

The code (GetSADForFormatting) works (Breakpoint for debugging) but the output is the very same: different between 100% and 150% scaling: Have I missed something?

Best regards
Attachments
Prot_150.png
Prot_150.png (8.8 KiB) Viewed 18818 times
Prot_100.png
Prot_100.png (6 KiB) Viewed 18818 times
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: RichViewEdit and WIndows Textscaling

Post by Sergey Tkachenko »

In addition to overriding GetSADForFormatting, you need to assign Canvas.PixelsPerInch = FInternalPixelsPerInch (before calling Init; and, if a canvas for drawing is different, before calling DrawPage/DrawPageAt
WLemmermeyer
Posts: 11
Joined: Fri Jun 06, 2014 5:32 am
Location: Germany

Re: RichViewEdit and WIndows Textscaling

Post by WLemmermeyer »

Thank you very very much!!!

I need also set PixelPoInch to a MetafileCanvas on which we are painting....
Post Reply