Page 1 of 1
RichViewEdit and WIndows Textscaling
Posted: Thu Jul 16, 2020 4:33 am
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
Re: RichViewEdit and WIndows Textscaling
Posted: Thu Jul 16, 2020 12:05 pm
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.
Re: RichViewEdit and WIndows Textscaling
Posted: Thu Jul 16, 2020 12:23 pm
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....
Re: RichViewEdit and WIndows Textscaling
Posted: Thu Jul 16, 2020 7:05 pm
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.
Re: RichViewEdit and WIndows Textscaling
Posted: Sat Jul 18, 2020 3:16 pm
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
Re: RichViewEdit and WIndows Textscaling
Posted: Mon Jul 20, 2020 8:12 am
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
Re: RichViewEdit and WIndows Textscaling
Posted: Tue Jul 21, 2020 6:31 am
by WLemmermeyer
Thank you very very much!!!
I need also set PixelPoInch to a MetafileCanvas on which we are painting....