floating point invalid operation

General TRichView support forum. Please post your questions here
Post Reply
Marcer
Posts: 31
Joined: Mon Mar 23, 2009 1:54 pm

floating point invalid operation

Post by Marcer »

Hi,

I use Delphi XE2, Richview 13.6.2 and Report Builder 14.02.

I try to change font name with this code :

Code: Select all

var
   oStr: TStringStream;
   iFont: Integer;
begin
   oStr := TStringStream.Create(Value);
   oStr.Position := 0;

   ppRichView.RichView.Clear;

   ppRichView.RichView.LoadRTFFromStream(oStr);

   for iFont := ppRichView.RichView.Style.TextStyles.Count - 1 downto 0 do
   begin
      if ( SameText(ppRichView.RichView.Style.TextStyles[iFont].FontName, 'MS Sans Serif') ) then
         ppRichView.RichView.Style.TextStyles[iFont].FontName := 'Microsoft Sans Serif'
      else if ( SameText(RichView.Style.TextStyles[iFont].FontName, 'Courier')) then
         ppRichView.RichView.Style.TextStyles[iFont].FontName := 'Courier New';
   end;

   ppRichView.RichView.Format;

   oStr.Free;
The error occur on call ppRichView.RichView.Format, and is occur in TRVStyle.GetAsDevicePixelsX because the PSaD.ppixScreen = 0

Other information:
ppRichView.RichView.Style.TextStyles.Count = 7
ppRichView.RichView.Style.TextStyles[0].FontName := 'MS Sans Serif'
ppRichView.RichView.Style.TextStyles[1].FontName := 'Arial'
ppRichView.RichView.Style.TextStyles[2].FontName := 'Arial'
ppRichView.RichView.Style.TextStyles[3].FontName := 'Arial'
ppRichView.RichView.Style.TextStyles[4].FontName := 'Arial'
ppRichView.RichView.Style.TextStyles[5].FontName := 'Arial'
ppRichView.RichView.Style.TextStyles[6].FontName := 'Arial'

In function "TRVStyle.GetAsDevicePixelsX"
Result := Round(Value / PSaD.ppixScreen * PSaD.ppixDevice)
Value = 0
PSaD.ppixScreen = 0
PSaD.ppixDevice = 1440

Best regards
Marcer
Posts: 31
Joined: Mon Mar 23, 2009 1:54 pm

Post by Marcer »

And I use Wrapper v1.13.1
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Just do not call ppRichView.RichView.Format. It is not needed, and, as you can see, leads to an exception
Marcer
Posts: 31
Joined: Mon Mar 23, 2009 1:54 pm

Post by Marcer »

If I dont call ppRichView.RichView.Format, all text within this style not print correctly.
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

ppRichView.RichView cannot be formatted using Format, it must be formatted by RB when it prepares a report.
When do you call this code? Can you create a simple test project?
Marcer
Posts: 31
Joined: Mon Mar 23, 2009 1:54 pm

Post by Marcer »

I test with not call format and it's ok.

Thanks Sergey!
Post Reply