📄 qm_qrfuns.pas
字号:
{*******************************************************}
{ }
{ QReportMaker 2.0 }
{ QR Functions }
{ }
{ Copyright (c) 2003,2004 by Zwm. }
{ }
{*******************************************************}
unit QM_QRFuns;
interface
uses
Windows, SysUtils, Graphics, Classes, Printers, QRCtrls, QuickRpt, QRPrntr;
var
QMQuickRep: TQuickRep;
function QM_FindBand(BandType: TQRBandType; clr: TColor): TQRBand;
procedure QM_ApplySetting(QM: TObject);
procedure QM_ChkPageCount;
implementation
uses QM_RConsole, QM_PQuickRep, QM_DCtrl, QM_Utils;
procedure QM_ApplySetting(QM: TObject);
var
i: Integer;
tmpWidth,tmpLength: Real;
Page: TQMPage;
begin
if QM is TQMReportConsole then
Page := TQMReportConsole(QM).Page
else if QM is TQMPrintQuickRep then
Page := TQMPrintQuickRep(QM).Page
else Exit;
if QMQuickRep = nil then Exit;
QMQuickRep.Page.PaperSize := QRPrntr.Custom;
if Page.Orientation = poPortrait then
begin
tmpLength := Page.Length * 100;
tmpWidth := Page.Width * 100;
end else
begin
tmpLength := Page.Width * 100;
tmpWidth := Page.Length * 100;
end;
QMQuickRep.Page.Length := Page.Length * 10;
QMQuickRep.Page.Width := Page.Width * 10;
QMQuickRep.Page.Orientation := poPortrait;
for i := 1 to 26 do
begin
if (abs(tmpLength - cQRPaperSizeMetrics[TQRPaperSize(i),1] * 10)<10) and
(abs(tmpWidth - cQRPaperSizeMetrics[TQRPaperSize(i),0] * 10)<10) then
begin
QMQuickRep.Page.PaperSize := TQRPaperSize(i);
QMQuickRep.Page.Orientation := Page.Orientation;
Break;
end;
end;
QMQuickRep.Page.TopMargin := page.TopMargin * 10;
QMQuickRep.Page.BottomMargin := page.BottomMargin * 10;
QMQuickRep.Page.LeftMargin := page.LeftMargin * 10;
QMQuickRep.Page.RightMargin := page.RightMargin * 10;
QMQuickRep.Page.Columns := Page.Columns;
QMQuickRep.Page.ColumnSpace := Page.ColumnSpace * 10;
if QM is TQMReportConsole then
with TQMReportConsole(QM) do
begin
QMQuickRep.Options := [];
if rcFirstPageHeader in Options then
QMQuickRep.Options := QMQuickRep.Options + [FirstPageHeader];
if rcLastPageFooter in Options then
QMQuickRep.Options := QMQuickRep.Options + [LastPageFooter];
QMQuickRep.ReportTitle := DocumentTitle;
QMQuickRep.Frame.DrawTop := Frame.DrawTop;
QMQuickRep.Frame.DrawBottom := Frame.DrawBottom;
QMQuickRep.Frame.DrawLeft := Frame.DrawLeft;
QMQuickRep.Frame.DrawRight := Frame.DrawRight;
QMQuickRep.Frame.Color := QM_PrintColor(TQMReportConsole(QM), Frame.Color);
QMQuickRep.Frame.Width := Frame.Width;
QMQuickRep.Frame.Style := Frame.Style;
end;
end;
function QM_FindBand(BandType: TQRBandType; clr: TColor): TQRBand;
var
QRBand: TQRCustomBand;
begin
case BandType of
rbTitle : QRBand := QMQuickRep.Bands.TitleBand;
rbPageHeader : QRBand := QMQuickRep.Bands.PageHeaderBand;
rbDetail : QRBand := QMQuickRep.Bands.DetailBand;
rbPageFooter : QRBand := QMQuickRep.Bands.PageFooterBand;
rbSummary : QRBand := QMQuickRep.Bands.SummaryBand;
rbColumnHeader : QRBand := QMQuickRep.Bands.ColumnHeaderBand;
else QRBand := QMQuickRep.Bands.TitleBand;
end;
if QRBand = nil then
begin
case BandType of
rbTitle :
begin
QMQuickRep.Bands.HasTitle := True;
QRBand := QMQuickRep.Bands.TitleBand;
end;
rbPageHeader :
begin
QMQuickRep.Bands.HasPageHeader := True;
QRBand := QMQuickRep.Bands.PageHeaderBand;
end;
rbDetail :
begin
QMQuickRep.Bands.HasDetail := True;
QRBand := QMQuickRep.Bands.DetailBand;
end;
rbPageFooter :
begin
QMQuickRep.Bands.HasPageFooter := True;
QRBand := QMQuickRep.Bands.PageFooterBand;
end;
rbSummary :
begin
QMQuickRep.Bands.HasSummary := True;
QRBand := QMQuickRep.Bands.SummaryBand;
end;
rbColumnHeader :
begin
QMQuickRep.Bands.HasColumnHeader := True;
QRBand := QMQuickRep.Bands.ColumnHeaderBand;
end;
else
begin
QMQuickRep.Bands.HasTitle := True;
QRBand := QMQuickRep.Bands.TitleBand;
end;
end;
QRBand.Height := 0;
QRBand.Color := clr;
QRBand.Tag := 1;
end else QRBand.Tag := 0;
Result := TQRBand(QRBand);
end;
procedure QM_ChkPageCount;
var
i,j: integer;
PageCount: string;
QRBand: TQRBand;
function GetPageCount(s: string): string;
var
ps:integer;
begin
ps := pos('#PAGECOUNT', s);
while ps>0 do
begin
Delete(s, ps, 10);
Insert(PageCount, s, ps);
ps := pos('#PAGECOUNT', s);
end;
Result := s;
end;
begin
//if not R_HasPageCount then exit;
PageCount := '0';
QMQuickRep.Prepare;
PageCount := IntToStr(QMQuickRep.QRPrinter.PageCount);
for i := 0 to QMQuickrep.ControlCount - 1 do
if QMQuickrep.Controls[i] is TQRBand then
begin
QRBand := TQRBand(QMQuickrep.Controls[i]);
for j := 0 to QRBand.ControlCount - 1 do
if QRBand.Controls[j].Tag = 9 then
if QRBand.Controls[j] is TQRLabel then
TQRLabel(QRBand.Controls[j]).Caption := GetPageCount(TQRLabel(QRBand.Controls[j]).Caption)
else if QRBand.Controls[j] is TQRExpr then
TQRExpr(QRBand.Controls[j]).Expression := GetPageCount(TQRExpr(QRBand.Controls[j]).Expression);
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -