QuickReport绘制中国式报表

unit Qrline;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
       Quickrpt;
type
  TQRLineStyle=(QRLineH,QRLineV,QRLineC,QRLineCR);
  TQRLine = class(TQRPrintable)
  private
    { Private declarations }
    FPen:TPen;
    FLineStyle:TQRLineStyle;
  protected
    { Protected declarations }
    procedure setPen(value:TPen);
    procedure setLineStyle(value:TQRLineStyle);
    procedure onPenChanged(Sender:TObject);
  public
    { Public declarations }
    constructor Create(AOwner:TComponent);override;
    destructor Destroy;override;
    procedure Paint;override;
    procedure Print(OfsX,OfsY:integer);override;
  published
    { Published declarations }
    property Pen:TPen read FPen write setPen;
    property LineStyle:TQRLineStyle read FLineStyle write setLineStyle;
  end;

procedure Register;

implementation

constructor TQRLine.Create(AOwner:TComponent);
begin
  inherited Create(AOwner);
  ControlStyle:=ControlStyle-[csOpaque];
  FPen:=Tpen.Create ;
  FPen.OnChange:=onPenChanged;
  width:=100;
  height:=100;
end;

destructor TQRLine.Destroy;
begin
  FPen.Free;
  inherited Destroy;
end;

procedure TQRLine.setPen(value:TPen);
begin
  FPen.Assign(value);
  invalidate;
end;

procedure TQRLine.setLineStyle(value:TQRLineStyle);
begin
  if FLineStyle<>value then
  begin
    FLineStyle:=value;
    invalidate;
  end;
end;

procedure TQRLine.onPenChanged(Sender:TObject);
begin
  invalidate;
end;

procedure TQRLine.Paint;
var
 calDiff:integer;
begin
  with Canvas do
  begin
    Pen:=FPen;
    calDiff:=Pen.Width div 2;
    MoveTo(calDiff,calDiff);
    if LineStyle=QRLineCR then begin
      MoveTo(calDiff,Height- calDiff);
    end;
    case LineStyle of
     QRLineH:LineTo(width,0+calDiff);
     QRLineV:LineTo(calDiff,Height);
     QRLineC:LineTo(width,Height);
     QRLineCR:LineTo(width,0);
    end;
  end;
end;

procedure TQRLine.Print(OfsX,OfsY:integer);
var
 CalcLeft,CalcTop,CalcRight,CalcBottom:integer;
begin
  with ParentReport.QRPrinter do
  begin
    Canvas.Pen:=FPen;
    CalcLeft:=XPos(OfsX+Size.Left);
    CalcTop:=YPos(OfsY+Size.Top);
    CalcRight:=XPos(OfsX+Size.Left+Size.Width);
    CalcBottom:=YPos(OfsY+Size.Top+Size.Height);
    with Canvas do
    begin
      MoveTo(CalcLeft,CalcTop);
      case LineStyle of
      QRLineH:LineTo(CalcRight,CalcTop);
      QRLineV:LineTo(CalcLeft,CalcBottom);
      QRLineC:LineTo(CalcRight,CalcBottom);
      end;
    end;
  end;
end;

procedure Register;
begin
  RegisterComponents('Qreport', [TQRLine]);
end;

end.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
方便quickreport控件自动换行问题 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, Grids, DBGrids; type TForm1 = class(TForm) DBGrid1: TDBGrid; BitBtn1: TBitBtn; btnPrev: TBitBtn; btnPrt: TBitBtn; btnExit: TBitBtn; Memo1: TMemo; procedure btnPrevClick(Sender: TObject); procedure btnPrtClick(Sender: TObject); procedure BitBtn1Click(Sender: TObject); procedure btnExitClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation uses Unit2,Unit3; {$R *.dfm} procedure TForm1.btnPrevClick(Sender: TObject); begin //调用QuickReport3模块 if Not Assigned(Form3) then Form3 := TForm3.Create(Application); //预览 Form3.QuickReport3.preview; end; procedure TForm1.btnPrtClick(Sender: TObject); begin //调用QuickReport3模块 if Not Assigned(Form3) then Form3 := TForm3.Create(Application); //打印 //Form3.QuickReport3.PreviewModal; Form3.QuickReport3.PrinterSetup; Form3.QuickReport3.Print; end; procedure TForm1.BitBtn1Click(Sender: TObject); begin with DM.ADOQyp do begin close; sql.Clear; sql.Add(' select BM,MC from zd_yp where bm like ''04443'' '); open; end; //Form3.QRMemo1.Lines.Text:= DM.ADOQyp.FieldValues['MC'].AsString; //Form3.QRMemo1.Lines.Text:= DM.ADOQyp.FieldByName('MC').AsString; //Form3.QRMemo1.Lines.Text:= Memo1.Text; Form3.QRRichText1.Lines.Text := DM.ADOQyp.FieldByName('MC').AsString; end; procedure TForm1.btnExitClick(Sender: TObject); begin close; end; end.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值