#1 2014-03-13 06:21:43

hadimoradi
Member
Registered: 2014-03-13
Posts: 5

Vertical & Horizontal problem when shade every other row

I have problem with frxMemoView.Frame.Typ property to print vertical & horizontal line when using following code

  //Print Rect around MemoView which exists in MasterData band
  if ShowRect then
    MemoView.Frame.Typ := [ftLeft, ftRight, ftTop, ftBottom];

  //shade every other row
  if ShadeEveryOtherRow then begin
    MemoView.Highlight.Condition := '(<Line#> mod 2) = 0';
    MemoView.Highlight.Color := clGray;
  end;

It works when using PDF Printer but SynPDF remove some lines
Compare

Do you have any idea?

Offline

#2 2014-04-01 15:51:15

andreas
Member
Registered: 2014-04-01
Posts: 3

Re: Vertical & Horizontal problem when shade every other row

I had similar problems with the export from FastReports. If there is a background color in a TfrxView object with a frame, then the frame lines are not drawn correctly.

As a workaround I patched TfrxView.DrawBackground, replacing FillRect(Rect(FX, FY, FX1, FY1)) by Rectangle(FX, FY, FX1+1, FY1+1)

procedure TfrxView.DrawBackground;
var
  br, oldbr: HBRUSH;
  OldPenStyle: TPenStyle;
begin
  with FCanvas do
  begin
    Brush.Style := FBrushStyle;
    if FColor <> clNone then
    begin
      Brush.Color := FColor;
      Brush.Style := bsSolid;
      // +++ original code +++
      // FillRect(Rect(FX, FY, FX1, FY1));
      // --- original code ---
      // +++ patched code +++
      OldPenStyle := Pen.Style;
      Pen.Style := psClear;
      Rectangle(FX, FY, FX1+1, FY1+1);
      Pen.Style := OldPenStyle;
      // --- patched code ---
    end;
    if FBrushStyle <> bsSolid then
    begin
      { Brush.Style := xxx does not work for some printers }
      {$IFDEF FPC}
      {$warning LCL: CreateHatchBrush() NOT IMPLEMENTED YET !}
      {TODO: CreateHatchBrush() implementation}
      br := LCLIntf.CreateSolidBrush(ColorToRGB(Self.Frame.Color));
      {$ELSE}
      br := CreateHatchBrush(Integer(FBrushStyle) - 2, ColorToRGB(Frame.Color));
      {$ENDIF}
      oldbr := SelectObject(Handle, br);
      Rectangle(FX, FY, FX1 + 1, FY1 + 1);
      SelectObject(Handle, oldbr);
      DeleteObject(br);
    end;
  end;
end;

Offline

#3 2014-04-07 11:55:59

hadimoradi
Member
Registered: 2014-03-13
Posts: 5

Re: Vertical & Horizontal problem when shade every other row

It works fine.
Thank you so much

Offline

#4 2015-11-27 07:10:00

andreas
Member
Registered: 2014-04-01
Posts: 3

Re: Vertical & Horizontal problem when shade every other row

I've recently upgraded to FastReport VCL 5. To apply the workaround there the method TfrxBrushFill.Draw must be patched.

procedure TfrxBrushFill.Draw(ACanvas: TCanvas; X, Y, X1, Y1: Integer; ScaleX,
  ScaleY: Extended);
var
  br, oldbr: HBRUSH;
  OldPStyle: TPenStyle;
begin
  with ACanvas do
  begin
    Brush.Style := Style;
//    FFill.Draw(FCanvas, FX, FY, FX1, FY1, FScaleX, FScaleY);
    if FBackColor <> clNone then
    begin
      Brush.Color := FBackColor;
      Brush.Style := bsSolid;
      // this is a workaround for export with SynPDF
      // +++ original code +++
      // FillRect(Rect(X, Y, X1, Y1));
      // --- original code ---
      // +++ patched code +++
      OldPStyle := Pen.Style;
      Pen.Style := psClear;
      Rectangle(X, Y, X1+1, Y1+1);
      Pen.Style := OldPStyle;
      // --- patched code ---
    end;
    if Style <> bsSolid then
    begin
      { Brush.Style := xxx does not work for some printers }
      { Brush.Style := xxx does not work for some printers }
{$IFDEF FPC}
{$warning LCL: CreateHatchBrush() NOT IMPLEMENTED YET !}
      {TODO: CreateHatchBrush() implementation}
      br := LCLIntf.CreateSolidBrush(ColorToRGB(FForeColor));
{$ELSE}
      br := CreateHatchBrush(Integer(Style) - 2, ColorToRGB(FForeColor));
{$ENDIF}
      oldbr := SelectObject(Handle, br);
      SetBkMode(Handle,TRANSPARENT);
      OldPStyle := Pen.Style;
      Pen.Style := psClear;
      Rectangle(X, Y, X1 + 1, Y1 + 1);
      SelectObject(Handle, oldbr);
      DeleteObject(br);
      Pen.Style := OldPStyle;
    end;
  end;
end;

Offline

Board footer

Powered by FluxBB