最菜的问题(100分)

  • 主题发起人 主题发起人 windows2005
  • 开始时间 开始时间
W

windows2005

Unregistered / Unconfirmed
GUEST, unregistred user!
报表中如何划上一条斜线....做为表头的一部分...谁能教我.
 
用RAVE,里面直接就有画线的图形,可以直接画斜线
 
我写了一个QuickRep的控件, 画格子的, 可以画斜线, 以下是源代码

{Inherited From TQRPrintable}
{主要属性}
{ property Caption: '/'解释为换行}
{ property LineLeft: Byte read FL write FL default 1;
property LineTop: Byte read FT write FT default 1;
property LineRight: Byte read FR write FR default 1;
property LineBottom: Byte read FB write FB default 1;
分别是四边的笔的宽度
property Splash: Boolean read FSplash write FSplash; //是否画斜线
}
unit QRHeadCellUnit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
QuickRpt;
type
TQRHeadCell = class(TQRPrintable)
private
{ Private declarations }
FL, FT, FR, FB: Byte;
FSplash: Boolean;
FData: String;
procedure PaintToCanvas(const ARect: TRect;
ACanvas: TCanvas;
Grayed: Boolean);
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner : TComponent);
override;
procedure Paint;
override;
procedure Print(OfsX, OfsY : integer);
override;
published
{ Published declarations }
// property Pen: TPen read FPen write FPen;
property LineLeft: Byte read FL write FL default 1;
property LineTop: Byte read FT write FT default 1;
property LineRight: Byte read FR write FR default 1;
property LineBottom: Byte read FB write FB default 1;
property Font;
property Brush;
property Caption;
property ParentFont;
property TransParent;
property Splash: Boolean read FSplash write FSplash;
property Data: String read FData write FData;
property OnMouseDown;
end;

procedure Register;
implementation
constructor TQRHeadCell.Create(AOwner : TComponent);
begin
inherited Create(AOwner);
FL := 1;
FT := 1;
FR := 1;
FB := 1;
end;
procedure TQRHeadCell.PaintToCanvas(const ARect: TRect;
ACanvas: TCanvas;
Grayed: Boolean);
var
TR: TRect;
H: Integer;
S: String;
I: Integer;
DC: HDC;
begin
S := Caption;
I := Pos('/', S);
while I > 0do
begin
S := #13;
I := Pos('/', S);
end;
ACanvas.Brush.Assign(Brush);
ACanvas.Font.Assign(Font);
//ACanvas.Pen.Assign(Pen);
//ACanvas.Brush.Color := clBlack;
ACanvas.FillRect(ARect);
{
TR := ARect;
Inc(TR.Left, FL);
Inc(TR.Top, FT);
Dec(TR.Right, FR);
Dec(TR.Bottom, FB);
ACanvas.Brush.Assign(Brush);
ACanvas.FillRect(TR);
}
if Grayed then
begin
ACanvas.Font.Color := clGrayText;
ACanvas.Pen.Color := clGray;
end else
begin
ACanvas.Pen.Color := clBlack;
end;
ACanvas.Pen.Style := psSolid;
ACanvas.Pen.Mode := pmCopy;
if FL > 0 then
begin
ACanvas.Pen.Width := FL;
MoveToEx(ACanvas.Handle, ARect.Left, ARect.Top, Nil);
LineTo(ACanvas.Handle, ARect.Left, ARect.Bottom);
end;
if FT > 0 then
begin
ACanvas.Pen.Width := FT;
MoveToEx(ACanvas.Handle, ARect.Left, ARect.Top, Nil);
LineTo(ACanvas.Handle, ARect.Right, ARect.Top);
end;
if FR > 0 then
begin
ACanvas.Pen.Width := FR;
MoveToEx(ACanvas.Handle, ARect.Right, ARect.Top, Nil);
LineTo(ACanvas.Handle, ARect.Right, ARect.Bottom);
end;
if FB > 0 then
begin
ACanvas.Pen.Width := FB;
MoveToEx(ACanvas.Handle, ARect.Left, ARect.Bottom, Nil);
LineTo(ACanvas.Handle, ARect.Right, ARect.Bottom);
end;
if Splash then
begin
ACanvas.Pen.Width := 1;
MoveToEx(ACanvas.Handle, ARect.Left, ARect.Top, Nil);
LineTo(ACanvas.Handle, ARect.Right + 1, ARect.Bottom + 1);
end;
TR := ARect;
SetTextAlign(ACanvas.Handle, TA_LEFT);
H := DrawText(ACanvas.Handle, PChar(S), Length(S), TR, DT_CALCRECT or DT_Center or DT_WordBreak);
TR := ARect;
H := (ARect.Bottom - ARect.Top - H) div 2;
TR.Top := ARect.Top + H + 1;
TR.Bottom := ARect.Bottom - H;
ACanvas.Brush.Style := bsClear;
DC := SaveDC(ACanvas.Handle);
IntersectClipRect(ACanvas.Handle, ARect.Left, ARect.Top, ARect.Right, ARect.Bottom);
DrawText(ACanvas.Handle, PChar(S), Length(S), TR, DT_Center or DT_WordBreak);
RestoreDC(ACanvas.Handle, DC);
end;

procedure TQRHeadCell.Paint;
var
ARect: TRect;
begin
ARect := ClientRect;
Inc(ARect.Top, FT div 2);
Inc(ARect.Left, FL div 2);
Dec(ARect.Bottom, (FB + 1) div 2);
Dec(ARect.Right, (FR + 1) div 2);
PaintToCanvas(ARect, Canvas, not Enabled);
end;

procedure TQRHeadCell.Print(OfsX, OfsY : integer);
var
ARect: TRect;
begin
with ParentReport.QRPrinterdo
begin
SetRect(ARect, XPos(OfsX + Size.Left),
YPos(OfsY + Size.Top),
XPos(OfsX + Size.Left + Size.Width),
YPos(OfsY + Size.Top + Size.Height));
PaintToCanvas(ARect, Canvas, False);
end;
end;

procedure Register;
begin
RegisterComponents('NEWQR', [TQRHeadCell]);
end;

end.
 
晕。。看起来好难哦。
我用的是FASTREPORT,在这里面能不能划斜线???
 
还有一个问题.......谁能告诉我。
BDE里如何连SQLSERVER服务器。
应该设置些什么构件,又如何设置呢?
 
没人可以帮我??是不知道还是不愿意说呢.
 
你得放置个BDE里的控件(table或query)放在form上,然后是datasource,再就是datacontrol,接着你要设置它们的属性~例如:BDE里的table就得设置databasename,tablename来连接你的SQLSERVER服务器,datasource.dataset指向table,而datacontrol就是用来显示数据的[:D]
 
1、要打印出斜线,可使用report machine
2、如果配置了ODBC数据源,并且在BDE管理器那里设置好了,再拖一个TDatabase控件,设置里面的相关属性(特别是Params属性),然后按楼上的方法就可以了。
 
OK,现在通过BDE的方式连接SQLSERVER已经成功,另外还有一个就是斜线问题.
TO dez_0609 你说的REPORT MACHINE,这是一个类似于FASTREPORT一样的东东吗?是不是要另外下载?
还有,我早上看了一下RAVE这个报表程序,在这里面可以直接划出斜线,但感觉这东东很复杂,不知道谁有没有些资料提供一下...谢谢...
 
多人接受答案了。
 
后退
顶部