📄 sctbtn.pas
字号:
unit SctBtn;
{ ----------------------------------------------------------------
Ace Reporter
Copyright 1995-1998 SCT Associates, Inc.
Written by Kevin Maher, Steve Tyrakowski
---------------------------------------------------------------- }
interface
{$I ace.inc}
uses
{$IFDEF WIN32}
windows,
{$ELSE}
wintypes, winprocs,
{$ENDIF}
SysUtils, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, Buttons, sctrep, psetup;
type
TSctBtnDest = (bdPrinter, bdScreen, bdDefault);
TSctBtnPrompt = (bpPrompt, bpNoPrompt, bpDefault);
TSctBtnDataRange = (brAllRecords, brSingleRecord, brDefault);
{ TSctOnBeforeRunEvent }
TSctOnBeforeRunEvent = procedure (PageSetup: TObject) of object;
TSctReportButton = class(TBitBtn)
private
{ Private declarations }
FReport: TSctReport;
FDestination: TSctBtnDest;
FPrompt: TSctBtnPrompt;
FOnBeforeRun: TSctOnBeforeRunEvent;
FDataRange: TSctBtnDataRange;
protected
{ Protected declarations }
procedure SetParent(AParent: TWinControl); override;
procedure Notification(AComponent: TComponent;
Operation: TOperation); override;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
procedure Click; override;
published
{ Published declarations }
property Report: TSctReport read FReport write FReport;
property Destination: TSctBtnDest read FDestination write FDestination;
property Prompt: TSctBtnPrompt read FPrompt write FPrompt;
property OnBeforeRun: TSctOnBeforeRunEvent read FOnBeforeRun write FOnBeforeRun;
property DataRange: TSctBtnDataRange read FDataRange write FDataRange;
end;
implementation
constructor TSctReportButton.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FDestination := bdDefault;
FPrompt := bpDefault;
FDataRange := brDefault;
end;
procedure TSctReportButton.Notification(AComponent: TComponent;
Operation: TOperation);
begin
Inherited Notification(AComponent, Operation);
if (AComponent is TSctReport) Then
begin
if (Operation = opRemove) And (TSctReport(AComponent) = Report) Then
Report := nil;
end;
end;
procedure TSctReportButton.Click;
var
nogo: Boolean;
PageSetup: TSctPageSetup;
begin
if FReport <> nil then
begin
nogo := false;
PageSetup := Report.Page.PageSetup;
if Destination <> bdDefault then
begin
if Destination = bdPrinter then PageSetup.Destination := destPrinter
else if Destination = bdScreen then PageSetup.Destination := destScreen;
end;
if Prompt <> bpDefault then
begin
if Prompt = bpPrompt then Report.Prompt := True
else Report.Prompt := False;
end;
if DataRange <> brDefault then
begin
if DataRange = brAllRecords Then TSctGroupPage(Report.Page).DataRange := drAllRecords
else TSctGroupPage(Report.Page).DataRange := drSingleRecord;
end;
if Assigned(FOnBeforeRun) then
begin
try
FOnBeforeRun( PageSetup );
except
nogo := True;
end;
end;
if Not nogo then FReport.Run;
end;
inherited Click;
end;
procedure TSctReportButton.SetParent(AParent: TWinControl);
begin
{ do this check so don't put my component on where is does not belong }
if (AParent = nil) Or (Not (AParent is TSctPage)
And Not (AParent is TSctBand) And Not (AParent is TSctReport) ) Then
begin
inherited SetParent(AParent);
end else Abort;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -