📄 frxadowizard.pas
字号:
{******************************************}
{ }
{ FastReport v4.0 }
{ Standard Report wizard for ADO }
{ }
{ Copyright (c) 1998-2008 }
{ by Alexander Tzyganenko, }
{ Fast Reports Inc. }
{ }
{******************************************}
unit frxAdoWizard;
interface
{$I frx.inc}
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ComCtrls, ExtCtrls, frxClass, frxDesgn;
type
TfrxStdWizard = class(TfrxCustomWizard)
public
class function GetDescription: String; override;
function Execute: Boolean; override;
end;
TfrxDotMatrixWizard = class(TfrxCustomWizard)
public
class function GetDescription: String; override;
function Execute: Boolean; override;
end;
TfrxStdEmptyWizard = class(TfrxCustomWizard)
public
class function GetDescription: String; override;
function Execute: Boolean; override;
end;
TfrxDMPEmptyWizard = class(TfrxCustomWizard)
public
class function GetDescription: String; override;
function Execute: Boolean; override;
end;
TfrxStdWizardForm = class(TForm)
Pages: TPageControl;
FieldsTab: TTabSheet;
GroupsTab: TTabSheet;
LayoutTab: TTabSheet;
FieldsLB: TListBox;
AddFieldB: TSpeedButton;
AddAllFieldsB: TSpeedButton;
RemoveFieldB: TSpeedButton;
RemoveAllFieldsB: TSpeedButton;
SelectedFieldsLB: TListBox;
SelectedFieldsL: TLabel;
FieldUpB: TSpeedButton;
FieldDownB: TSpeedButton;
AvailableFieldsLB: TListBox;
AddGroupB: TSpeedButton;
RemoveGroupB: TSpeedButton;
GroupsLB: TListBox;
GroupsL: TLabel;
GroupUpB: TSpeedButton;
GroupDownB: TSpeedButton;
AvailableFieldsL: TLabel;
BackB: TButton;
NextB: TButton;
FinishB: TButton;
FitWidthCB: TCheckBox;
Step2L: TLabel;
Step3L: TLabel;
Step4L: TLabel;
StyleTab: TTabSheet;
Step5L: TLabel;
ScrollBox1: TScrollBox;
StylePB: TPaintBox;
StyleLB: TListBox;
OrientationL: TGroupBox;
LayoutL: TGroupBox;
PortraitImg: TImage;
LandscapeImg: TImage;
PortraitRB: TRadioButton;
LandscapeRB: TRadioButton;
TabularRB: TRadioButton;
ColumnarRB: TRadioButton;
ScrollBox2: TScrollBox;
LayoutPB: TPaintBox;
AvailableFieldsL1: TLabel;
DataTab: TTabSheet;
Step1L: TLabel;
ConnectionCB: TComboBox;
TableL: TLabel;
TablesLB: TListBox;
orL: TLabel;
CreateQueryB: TButton;
ConnectionL: TLabel;
ConfigureConnB: TSpeedButton;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure AddFieldBClick(Sender: TObject);
procedure AddAllFieldsBClick(Sender: TObject);
procedure RemoveFieldBClick(Sender: TObject);
procedure RemoveAllFieldsBClick(Sender: TObject);
procedure AddGroupBClick(Sender: TObject);
procedure RemoveGroupBClick(Sender: TObject);
procedure FieldUpBClick(Sender: TObject);
procedure FieldDownBClick(Sender: TObject);
procedure GroupUpBClick(Sender: TObject);
procedure GroupDownBClick(Sender: TObject);
procedure NextBClick(Sender: TObject);
procedure BackBClick(Sender: TObject);
procedure GroupsTabShow(Sender: TObject);
procedure StylePBPaint(Sender: TObject);
procedure PortraitRBClick(Sender: TObject);
procedure PagesChange(Sender: TObject);
procedure StyleLBClick(Sender: TObject);
procedure FinishBClick(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure LayoutPBPaint(Sender: TObject);
procedure TabularRBClick(Sender: TObject);
procedure ConnectionCBClick(Sender: TObject);
procedure ConfigureConnBClick(Sender: TObject);
procedure TablesLBClick(Sender: TObject);
procedure CreateQueryBClick(Sender: TObject);
private
FDataset: TfrxDataset;
FDesigner: TfrxDesignerForm;
FDotMatrix: Boolean;
FLayoutReport: TfrxReport;
FReport: TfrxReport;
FStyleReport: TfrxReport;
FStyleSheet: TfrxStyleSheet;
procedure DrawSample(PaintBox: TPaintBox; Report: TfrxReport);
procedure FillConnections;
procedure FillFields;
procedure FillTables;
procedure UpdateAvailableFields;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
implementation
{$R *.DFM}
{$R *.RES}
uses
frxEditReportData, frxDsgnIntf, frxRes, frxUtils, frxDMPClass,
IniFiles, Registry, Printers, frxADOComponents, frxConnEditor;
const
StyleReport =
'<?xml version="1.0" encoding="utf-8"?>' +
'<TfrxReport>' +
'<TfrxReportPage>' +
'<TfrxMemoView Width="439,65337" Height="26" HAlign="haCenter" Text="Customers" Style="Title" VAlign="vaCenter"/>' +
'<TfrxMemoView Top="36" Width="253" Height="20" Style="Header line"/>' +
'<TfrxMemoView Top="36" Width="126,96846" Height="20" Text="Company" Style="Header"/>' +
'<TfrxMemoView Left="137,74799" Top="36" Width="126,2047" Height="20" Text="Address" Style="Header"/>' +
'<TfrxMemoView Top="60,47248" Width="264,5671" Height="26,45671" Text="Action Club" Style="Group header" VAlign="vaCenter"/>' +
'<TfrxMemoView Top="92" Width="126,96846" Height="20" Text="Action Club" Style="Data"/>' +
'<TfrxMemoView Left="137,74799" Top="92" Width="126,2047" Height="20" Text="PO Box 5451-F" Style="Data"/>' +
'<TfrxMemoView Top="112" Width="126,96846" Height="20" Text="Action Diver Supply" Style="Data"/>' +
'<TfrxMemoView Left="137,74799" Top="112" Width="126,2047" Height="20" Text="Blue Spar Box #3" Style="Data"/>' +
'<TfrxMemoView Top="132" Width="126,96846" Height="20" Text="Adventure Undersea" Style="Data"/>' +
'<TfrxMemoView Left="137,74799" Top="132" Width="126,2047" Height="20" Text="PO Box 744" Style="Data"/>' +
'<TfrxMemoView Top="157,98423" Width="264,47248" Height="18" Text="Count: 3" Style="Group footer"/>' +
'</TfrxReportPage>' +
'</TfrxReport>';
LayoutTabularReport =
'<?xml version="1.0" encoding="utf-8"?>' +
'<TfrxReport>' +
'<TfrxReportPage>' +
'<TfrxMemoView Left="0" Top="0" Width="338,1107" Height="22,67718" HAlign="haCenter" Style="Title" VAlign="vaCenter" Text="Report"/>' +
'<TfrxMemoView Left="0" Top="26,45671" Width="151,1812" Height="22,67718" Style="Header" Text="Company"/>' +
'<TfrxMemoView Left="151,1812" Top="26,45671" Width="139,84261" Height="22,67718" Style="Header" Text="Address"/>' +
'<TfrxMemoView Left="0" Top="49,13389" Width="151,1812" Height="18,89765" Style="Data" Text="Action Club"/>' +
'<TfrxMemoView Left="151,1812" Top="49,13389" Width="139,84261" Height="18,89765" Style="Data" Text="PO Box 5451-F"/>' +
'<TfrxMemoView Left="0" Top="68,03154" Width="151,1812" Height="18,89765" Style="Data" Text="Action Diver Supply"/>' +
'<TfrxMemoView Left="151,1812" Top="68,03154" Width="139,84261" Height="18,89765" Style="Data" Text="Blue Spar Box #3"/>' +
'<TfrxMemoView Left="0" Top="86,92919" Width="151,1812" Height="18,89765" Style="Data" Text="Adventure Undersea"/>' +
'<TfrxMemoView Left="151,1812" Top="86,92919" Width="139,84261" Height="18,89765" Style="Data" Text="PO Box 744"/>' +
'<TfrxMemoView Left="0" Top="105,82684" Width="151,1812" Height="18,89765" Style="Data" Text="American SCUBA Supply"/>' +
'<TfrxMemoView Left="151,1812" Top="105,82684" Width="139,84261" Height="18,89765" Style="Data" Text="1739 Atlantic Avenue"/>' +
'<TfrxMemoView Left="0" Top="124,72449" Width="151,1812" Height="18,89765" Style="Data" Text="Aquatic Drama"/>' +
'<TfrxMemoView Left="151,1812" Top="124,72449" Width="139,84261" Height="18,89765" Style="Data" Text="921 Everglades Way"/>' +
'<TfrxMemoView Left="0" Top="143,62214" Width="151,1812" Height="18,89765" Style="Data" Text="Blue Glass Happiness"/>' +
'<TfrxMemoView Left="151,1812" Top="143,62214" Width="139,84261" Height="18,89765" Style="Data" Text="6345 W. Shore Lane"/>' +
'</TfrxReportPage>' +
'</TfrxReport>';
LayoutColumnarReport =
'<?xml version="1.0" encoding="utf-8"?>' +
'<TfrxReport>' +
'<TfrxReportPage>' +
'<TfrxMemoView Left="0" Top="0" Width="338,1107" Height="22,67718" HAlign="haCenter" Style="Title" VAlign="vaCenter" Text="Report"/>' +
'<TfrxMemoView Left="0" Top="26,45671" Width="64" Height="18,89765" Style="Header" Text="Company"/>' +
'<TfrxMemoView Left="82,89765" Top="26,45671" Width="225" Height="18,89765" Style="Data" Text="Action Club"/>' +
'<TfrxMemoView Left="0" Top="45,35436" Width="64" Height="18,89765" Style="Header" Text="Address"/>' +
'<TfrxMemoView Left="82,89765" Top="45,35436" Width="225" Height="18,89765" Style="Data" Text="PO Box 5451-F"/>' +
'<TfrxMemoView Left="0" Top="64,25201" Width="64" Height="18,89765" Style="Header" Text="Phone"/>' +
'<TfrxMemoView Left="82,89765" Top="64,25201" Width="114" Height="18,89765" Style="Data" Text="813-870-0239"/>' +
'<TfrxMemoView Left="0" Top="83,14966" Width="64" Height="18,89765" Style="Header" Text="FAX"/>' +
'<TfrxMemoView Left="82,89765" Top="83,14966" Width="114" Height="18,89765" Style="Data" Text="813-870-0282"/>' +
'<TfrxMemoView Left="0" Top="120,94496" Width="64" Height="18,89765" Style="Header" Text="Company"/>' +
'<TfrxMemoView Left="82,89765" Top="120,94496" Width="225" Height="18,89765" Style="Data" Text="Action Diver Supply"/>' +
'<TfrxMemoView Left="0" Top="139,84261" Width="64" Height="18,89765" Style="Header" Text="Address"/>' +
'<TfrxMemoView Left="82,89765" Top="139,84261" Width="225" Height="18,89765" Style="Data" Text="Blue Spar Box #3"/>' +
'<TfrxMemoView Left="0" Top="158,74026" Width="64" Height="18,89765" Style="Header" Text="Phone"/>' +
'<TfrxMemoView Left="82,89765" Top="158,74026" Width="114" Height="18,89765" Style="Data" Text="22-44-500211"/>' +
'</TfrxReportPage>' +
'</TfrxReport>';
Style =
'<?xml version="1.0" encoding="utf-8"?>' +
'<stylesheet>' +
'<style Name="FastReport">' +
'<item Name="Title" Color="8388608" Font.Color="16777215" Font.Height="-16" Font.Style="1"/>' +
'<item Name="Header" Color="536870911" Font.Color="128" Font.Style="1"/>' +
'<item Name="Group header" Color="15790320" Font.Style="1"/>' +
'<item Name="Data" Color="536870911"/>' +
'<item Name="Group footer" Color="536870911" Font.Style="1"/>' +
'<item Name="Header line" Color="536870911" Frame.Typ="8" Frame.Width="2"/>' +
'</style>' +
'<style Name="Standard">' +
'<item Name="Title" Color="536870911" Font.Height="-16" Font.Style="1"/>' +
'<item Name="Header" Color="536870911" Font.Style="1"/>' +
'<item Name="Group header" Color="536870911" Frame.Typ="8"/>' +
'<item Name="Data" Color="536870911"/>' +
'<item Name="Group footer" Color="536870911" Frame.Typ="4"/>' +
'<item Name="Header line" Color="536870911" Frame.Typ="8" Frame.Width="2"/>' +
'</style>' +
'<style Name="Soft gray">' +
'<item Name="Title" Color="14211288" Font.Height="-16" Font.Style="1"/>' +
'<item Name="Header" Color="15790320" Font.Style="1"/>' +
'<item Name="Group header" Color="15790320" Font.Style="1"/>' +
'<item Name="Data" Color="536870911" Font.Style="0"/>' +
'<item Name="Group footer" Color="536870911" Frame.Typ="4"/>' +
'<item Name="Header line" Color="536870911" Frame.Width="2"/>' +
'</style>' +
'<style Name="Corporate">' +
'<item Name="Title" Color="0" Font.Color="16777215" Font.Height="-16" Font.Style="1"/>' +
'<item Name="Header" Color="0" Font.Color="16777215" Font.Style="1"/>' +
'<item Name="Group header" Color="52479" Font.Style="1"/>' +
'<item Name="Data" Color="536870911"/>' +
'<item Name="Group footer" Color="536870911" Font.Style="1"/>' +
'<item Name="Header line" Color="536870911" Frame.Width="2"/>' +
'</style>' +
'</stylesheet>';
{ TfrxStdWizard }
class function TfrxStdWizard.GetDescription: String;
begin
Result := frxResources.Get('wzStd');
end;
function TfrxStdWizard.Execute: Boolean;
begin
with TfrxStdWizardForm.Create(Owner) do
begin
FDesigner := TfrxDesignerForm(Self.Designer);
FReport := Report;
Result := ShowModal = mrOk;
Free;
end;
end;
{ TfrxDotMatrixWizard }
class function TfrxDotMatrixWizard.GetDescription: String;
begin
Result := frxResources.Get('wzDMP');
end;
function TfrxDotMatrixWizard.Execute: Boolean;
begin
with TfrxStdWizardForm.Create(Owner) do
begin
FDesigner := TfrxDesignerForm(Self.Designer);
FDotMatrix := True;
FReport := Report;
Result := ShowModal = mrOk;
Free;
end;
end;
{ TfrxStdEmptyWizard }
class function TfrxStdEmptyWizard.GetDescription: String;
begin
Result := frxResources.Get('wzStdEmpty');
end;
function TfrxStdEmptyWizard.Execute: Boolean;
var
Page: TfrxReportPage;
begin
Result := True;
try
Designer.Lock;
Report.Clear;
Report.FileName := '';
Report.DotMatrixReport := False;
Page := TfrxReportPage.Create(Report);
Page.Name := 'Page1';
Page.SetDefaults;
finally
Designer.ReloadReport;
end;
end;
{ TfrxDMPEmptyWizard }
class function TfrxDMPEmptyWizard.GetDescription: String;
begin
Result := frxResources.Get('wzDMPEmpty');
end;
function TfrxDMPEmptyWizard.Execute: Boolean;
var
Page: TfrxReportPage;
begin
Result := True;
try
Designer.Lock;
Report.Clear;
Report.FileName := '';
Report.DotMatrixReport := True;
Page := TfrxDMPPage.Create(Report);
Page.Name := 'Page1';
Page.SetDefaults;
finally
Designer.ReloadReport;
end;
end;
{ TfrxStdWizardForm }
constructor TfrxStdWizardForm.Create(AOwner: TComponent);
var
s: TStringStream;
begin
inherited;
FStyleReport := TfrxReport.Create(nil);
s := TStringStream.Create(StyleReport);
FStyleReport.LoadFromStream(s);
s.Free;
FLayoutReport := TfrxReport.Create(nil);
FStyleSheet := TfrxStyleSheet.Create;
if FileExists(ExtractFilePath(Application.ExeName) + 'wizstyle.xml') then
FStyleSheet.LoadFromFile(ExtractFilePath(Application.ExeName) + 'wizstyle.xml')
else
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -