请问在quickrep里面可以画出斜线吗?(100分)

  • 主题发起人 主题发起人 zgqone
  • 开始时间 开始时间
Z

zgqone

Unregistered / Unconfirmed
GUEST, unregistred user!
除了放图片之外,有没其它方法?
 
来自Hubdog的葵花宝典
unit qrline;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
quickrpt;

type
TQRLineStyle = (QRLineH,QRLineV,QRLineC);

TQRLine = class(TQRPrintable)
private
FPen: TPen;
FLineStyle: TQRLineStyle;
procedure setPen(value: TPen);
procedure setLineStyle(value: TQRLineStyle);
procedure onPenChanged(Sendoer: TObject);
protected
{ Protected declarations }
public
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;

procedure Paint;
override;
procedure Print(OfsX, OfsY : integer);
override;
published
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(Sendoer: TObject);
begin

Invalidate;
end;


procedure TQRLine.Paint;
var
calDiff: integer;
begin

with Canvasdo

begin

Pen := FPen;
calDiff := Pen.Width div 2;
MoveTo(calDiff,calDiff);
case LineStyle of
QRLineH: LineTo(width, 0 + calDiff);
QRLineV: LineTo(calDiff, Height);
QRLineC: LineTo(width, Height);
end;

end;

end;


procedure TQRLine.Print(OfsX, OfsY : integer);
var
CalcLeft,
CalcTop,
CalcRight,
CalcBottom: integer;
begin

with ParentReport.QRPrinterdo

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 Canvasdo

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.


 
这是一个定义的控件吗?我想我在别的机器上装了delphi,不用再装别的控件,
可以实现划斜的功能,行吗?
 
那不行,必须安装这个控件,这是一个控件的源代码,直接保存成pas文件,然后安装就可以了。
 
后退
顶部