以下是我两年前写的一个解决不能画斜线的一个继承于TCQSHARP的控件,
好象也解决了线不能连续的问题, 至少对你应该有帮助.
unit ANCityShape;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
QuickRpt, Qrctrls;
type
TLines = ( None,VLineFLX,TopBottom,BottomTop ) ;
TANCityShape = class(TQRShape)
private
FVHeight: Integer;
FLineType:TLines ;
procedure SetFLineType(Value:TLines) ;
procedure SetFVHeight(Value:Integer) ;
protected
procedure Print(OfsX, OfsY : integer);
override;
procedure Paint ;Override ;
public
published
property LineType:TLines Read FLineType Write SetFLineType ;
property VHeight:Integer Read FVHeight Write SetFVHeight ;
end;
procedure Register;
implementation
procedure TANCityShape.SetFLineType(Value:TLines);
begin
if Value<>FLineType then
begin
FLineType:=Value ;
Invalidate ;
end ;
end ;
procedure TANCityShape.SetFVHeight(Value:Integer);
begin
FVHeight:=Value ;
Invalidate ;
end ;
procedure TANCityQRShape.Paint ;
begin
case LineType of
BottomTop:
begin
Canvas.MoveTo(0,Height) ;
Canvas.LineTo(width,0 ) ;
end ;
TopBottom:
begin
Canvas.MoveTo(0,0) ;
Canvas.LineTo(width,Height ) ;
end ;
None:
begin
Height := Parent.Height ;
Top:=0 ;
Width:=4 ;
Shape:=qrsVertLine ;
Inherited Paint ;
end ;
VLineFLX:
begin
Height := Parent.Height;
Top:=0 ;
Width:=4 ;
Shape:=qrsVertLine ;
Inherited Paint ;
end ;
end ;
end ;
procedure TANCityShape.Print(OfsX,OfsY : Integer);
begin
with QRPrinterdo
begin
case LineType of
BottomTop:
begin
Canvas.MoveTo(XPos(OfsX + Size.Left), YPos(OfsY + Size.Top)+Height) ;
Canvas.LineTo(XPos(OfsX + Size.Left)+width,YPos(OfsY + Size.Top) ) ;
end ;
TopBottom:
begin
Canvas.MoveTo(XPos(OfsX + Size.Left), YPos(OfsY + Size.Top)) ;
Canvas.LineTo(XPos(OfsX + Size.Left)+Width,YPos(OfsY + Size.Top)+Height ) ;
end ;
None:
begin
Inherited Print(OfsX,OfsY ) ;
end ;
VLineFLX:
begin
Canvas.MoveTo(XPos(OfsX + Size.Left), YPos(OfsY + Size.Top)) ;
Canvas.LineTo(XPos(OfsX + Size.Left),YPos(OfsY + Size.Top)+FVHeight ) ;
end ;
end ;
end;
end;
procedure Register;
begin
RegisterComponents('QReport', [TANCityShape]);
end;
end.