{******************************************} { } { FastReport VCL } { Standard Report wizard for ADO } { } { Copyright (c) 1998-2021 } { by Fast Reports Inc. } { } {******************************************} unit frxAdoWizard; interface {$I frx.inc} uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, ComCtrls, ExtCtrls, frxClass, frxDesgn, frxBaseForm; 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(TfrxBaseForm) 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 = '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + ''; LayoutTabularReport = '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + ''; LayoutColumnarReport = '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + ''; Style = '' + '' + '' + '' + '' + '' + ''; { 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 s := TStringStream.Create(Style); FStyleSheet.LoadFromStream(s); s.Free; end; end; destructor TfrxStdWizardForm.Destroy; begin FStyleReport.Free; FLayoutReport.Free; FStyleSheet.Free; inherited; end; procedure TfrxStdWizardForm.FormCreate(Sender: TObject); var bmp: TBitmap; begin Caption := frxGet(5600); DataTab.Caption := frxGet(5601); FieldsTab.Caption := frxGet(5602); GroupsTab.Caption := frxGet(5603); LayoutTab.Caption := frxGet(5604); StyleTab.Caption := frxGet(5605); Step1L.Caption := frxGet(5606); Step2L.Caption := frxGet(5607); Step3L.Caption := frxGet(5608); Step4L.Caption := frxGet(5609); Step5L.Caption := frxGet(5610); AddFieldB.Caption := frxGet(5611); AddAllFieldsB.Caption := frxGet(5612); RemoveFieldB.Caption := frxGet(5613); RemoveAllFieldsB.Caption := frxGet(5614); AddGroupB.Caption := frxGet(5615); RemoveGroupB.Caption := frxGet(5616); SelectedFieldsL.Caption := frxGet(5617); AvailableFieldsL.Caption := frxGet(5618); AvailableFieldsL1.Caption := frxGet(5618); GroupsL.Caption := frxGet(5619); OrientationL.Caption := frxGet(5620); LayoutL.Caption := frxGet(5621); PortraitRB.Caption := frxGet(5622); LandscapeRB.Caption := frxGet(5623); TabularRB.Caption := frxGet(5624); ColumnarRB.Caption := frxGet(5625); FitWidthCB.Caption := frxGet(5626); BackB.Caption := frxGet(5627); NextB.Caption := frxGet(5628); FinishB.Caption := frxGet(5629); ConnectionL.Caption := frxGet(5632); TableL.Caption := frxGet(5633); orL.Caption := frxGet(5634); CreateQueryB.Caption := frxGet(5635); ConfigureConnB.Hint := frxGet(5636); bmp := TBitmap.Create; bmp.Width := 16; bmp.Height := 16; bmp.Canvas.Brush.Color := clOlive; bmp.Canvas.FillRect(Rect(0, 0, 16, 16)); frxResources.MainButtonImages.Draw(bmp.Canvas, 0, 0, 69); ConfigureConnB.Glyph := bmp; bmp.Free; if UseRightToLeftAlignment then FlipChildren(True); end; procedure TfrxStdWizardForm.FormShow(Sender: TObject); var Page: TfrxReportPage; begin FDesigner.Lock; FReport.Clear; if FDotMatrix then Page := TfrxDMPPage.Create(FReport) else Page := TfrxReportPage.Create(FReport); Page.Name := 'Page1'; Page.SetDefaults; FDesigner.ReloadReport; FillConnections; ConnectionCB.ItemIndex := 0; ConnectionCBClick(nil); FStyleSheet.GetList(StyleLB.Items); StyleLB.ItemIndex := 0; StyleLBClick(nil); TabularRBClick(nil); if FDotMatrix then StyleTab.Free; end; procedure TfrxStdWizardForm.FillConnections; var ini: TRegistry; begin ConnectionCB.Items.Clear; ini := TRegistry.Create; try ini.RootKey := HKEY_LOCAL_MACHINE; if ini.OpenKeyReadOnly(DEF_REG_CONNECTIONS, False) then begin ini.GetValueNames(ConnectionCB.Items); ini.CloseKey; end ini.RootKey := HKEY_CURRENT_USER; if ini.OpenKeyReadOnly(DEF_REG_CONNECTIONS, False) then begin ini.GetValueNames(ConnectionCB.Items); ini.CloseKey; end ini.RootKey := HKEY_CURRENT_USER; finally ini.Free; end; end; procedure TfrxStdWizardForm.FillFields; begin FieldsLB.Clear; SelectedFieldsLB.Clear; UpdateAvailableFields; if FDataset <> nil then FDataset.GetFieldList(FieldsLB.Items); if FieldsLB.Items.Count <> 0 then begin FieldsLB.ItemIndex := 0; FieldsLB.Selected[0] := True; end; end; procedure TfrxStdWizardForm.FillTables; begin frxADOGetTableNames(ADOComponents.DefaultDatabase, TablesLB.Items, False); end; procedure TfrxStdWizardForm.UpdateAvailableFields; begin AvailableFieldsLB.Items := SelectedFieldsLB.Items; GroupsLB.Clear; end; procedure TfrxStdWizardForm.DrawSample(PaintBox: TPaintBox; Report: TfrxReport); var i: Integer; c: TfrxComponent; begin with PaintBox do begin Canvas.Pen.Color := clBlack; Canvas.Brush.Color := clWindow; Canvas.Rectangle(0, 0, Width, Height); for i := 0 to Report.AllObjects.Count - 1 do begin c := Report.AllObjects[i]; if c is TfrxCustomMemoView then with TfrxCustomMemoView(c) do Draw(Canvas, 1, 1, 10, 10); end; end; end; procedure TfrxStdWizardForm.ConnectionCBClick(Sender: TObject); begin FReport.ReportOptions.ConnectionName := ConnectionCB.Items[ConnectionCB.ItemIndex]; FillTables; end; procedure TfrxStdWizardForm.ConfigureConnBClick(Sender: TObject); begin with TfrxConnEditorForm.Create(nil) do begin Report := FReport; ShowModal; Free; end; FillConnections; ConnectionCB.ItemIndex := 0; ConnectionCBClick(nil); end; procedure TfrxStdWizardForm.TablesLBClick(Sender: TObject); begin if FDataset <> nil then FDataset.Free; FDataset := TfrxADOTable.DesignCreate(FReport.Pages[0], 0); FDataset.CreateUniqueName; TfrxADOTable(FDataset).TableName := TablesLB.Items[TablesLB.ItemIndex]; TfrxADOTable(FDataset).UserName := TfrxADOTable(FDataset).TableName; FillFields; end; procedure TfrxStdWizardForm.CreateQueryBClick(Sender: TObject); var ed: TfrxComponentEditor; begin if FDataset <> nil then FDataset.Free; FDataset := TfrxADOQuery.DesignCreate(FReport.Pages[0], 0); FDataset.CreateUniqueName; ed := frxComponentEditors.GetComponentEditor(FDataset, FDesigner, nil); try ed.Edit; finally ed.Free; end; FillFields; end; procedure TfrxStdWizardForm.AddFieldBClick(Sender: TObject); var i, j: Integer; begin if FieldsLB.ItemIndex = -1 then Exit; i := 0; j := -1; while i < FieldsLB.Items.Count do if FieldsLB.Selected[i] then begin if j = -1 then j := i; SelectedFieldsLB.Items.Add(FieldsLB.Items[i]); FieldsLB.Items.Delete(i); end else Inc(i); if j = FieldsLB.Items.Count then Dec(j); if j <> -1 then begin FieldsLB.ItemIndex := j; FieldsLB.Selected[j] := True; end; UpdateAvailableFields; end; procedure TfrxStdWizardForm.AddAllFieldsBClick(Sender: TObject); begin if FieldsLB.Items.Count = 0 then Exit; FillFields; SelectedFieldsLB.Items := FieldsLB.Items; FieldsLB.Items.Clear; UpdateAvailableFields; end; procedure TfrxStdWizardForm.RemoveFieldBClick(Sender: TObject); var i, j: Integer; begin if SelectedFieldsLB.ItemIndex = -1 then Exit; i := 0; j := -1; while i < SelectedFieldsLB.Items.Count do if SelectedFieldsLB.Selected[i] then begin if j = -1 then j := i; FieldsLB.Items.Add(SelectedFieldsLB.Items[i]); SelectedFieldsLB.Items.Delete(i); end else Inc(i); if j = SelectedFieldsLB.Items.Count then Dec(j); if j <> -1 then begin SelectedFieldsLB.ItemIndex := j; SelectedFieldsLB.Selected[j] := True; end; UpdateAvailableFields; end; procedure TfrxStdWizardForm.RemoveAllFieldsBClick(Sender: TObject); begin FillFields; end; procedure TfrxStdWizardForm.AddGroupBClick(Sender: TObject); var i: Integer; begin i := AvailableFieldsLB.ItemIndex; if i = -1 then Exit; GroupsLB.Items.Add(AvailableFieldsLB.Items[i]); AvailableFieldsLB.Items.Delete(i); AvailableFieldsLB.ItemIndex := i; end; procedure TfrxStdWizardForm.RemoveGroupBClick(Sender: TObject); var i: Integer; begin i := GroupsLB.ItemIndex; if i = -1 then Exit; AvailableFieldsLB.Items.Add(GroupsLB.Items[i]); GroupsLB.Items.Delete(i); GroupsLB.ItemIndex := i; end; procedure TfrxStdWizardForm.FieldUpBClick(Sender: TObject); var i: Integer; begin i := SelectedFieldsLB.ItemIndex; if i < 1 then Exit; SelectedFieldsLB.Items.Exchange(i, i - 1); UpdateAvailableFields; end; procedure TfrxStdWizardForm.FieldDownBClick(Sender: TObject); var i: Integer; begin i := SelectedFieldsLB.ItemIndex; if (i = -1) or (SelectedFieldsLB.Items.Count = 0) or (i = SelectedFieldsLB.Items.Count - 1) then Exit; SelectedFieldsLB.Items.Exchange(i, i + 1); SelectedFieldsLB.ItemIndex := i + 1; UpdateAvailableFields; end; procedure TfrxStdWizardForm.GroupUpBClick(Sender: TObject); var i: Integer; begin i := GroupsLB.ItemIndex; if i < 1 then Exit; GroupsLB.Items.Exchange(i, i - 1); end; procedure TfrxStdWizardForm.GroupDownBClick(Sender: TObject); var i: Integer; begin i := GroupsLB.ItemIndex; if (i = -1) or (i = GroupsLB.Items.Count - 1) then Exit; GroupsLB.Items.Exchange(i, i + 1); GroupsLB.ItemIndex := i + 1; end; procedure TfrxStdWizardForm.NextBClick(Sender: TObject); begin Pages.SelectNextPage(True); PagesChange(nil); end; procedure TfrxStdWizardForm.BackBClick(Sender: TObject); begin Pages.SelectNextPage(False); PagesChange(nil); end; procedure TfrxStdWizardForm.PagesChange(Sender: TObject); begin if not FDotMatrix then NextB.Enabled := Pages.ActivePage <> StyleTab else NextB.Enabled := Pages.ActivePage <> LayoutTab; BackB.Enabled := Pages.ActivePage <> DataTab; end; procedure TfrxStdWizardForm.GroupsTabShow(Sender: TObject); begin AvailableFieldsLB.ItemIndex := 0; end; procedure TfrxStdWizardForm.StylePBPaint(Sender: TObject); begin DrawSample(StylePB, FStyleReport); end; procedure TfrxStdWizardForm.LayoutPBPaint(Sender: TObject); begin DrawSample(LayoutPB, FLayoutReport); end; procedure TfrxStdWizardForm.PortraitRBClick(Sender: TObject); begin PortraitImg.Visible := PortraitRB.Checked; LandscapeImg.Visible := LandscapeRB.Checked; end; procedure TfrxStdWizardForm.StyleLBClick(Sender: TObject); begin FStyleReport.Styles := FStyleSheet.Find(StyleLB.Items[StyleLB.ItemIndex]); StylePBPaint(nil); end; procedure TfrxStdWizardForm.TabularRBClick(Sender: TObject); var s: TStringStream; begin if TabularRB.Checked then s := TStringStream.Create(LayoutTabularReport) else s := TStringStream.Create(LayoutColumnarReport); FLayoutReport.LoadFromStream(s); s.Free; FLayoutReport.Styles := FStyleSheet[0]; LayoutPBPaint(nil); end; procedure TfrxStdWizardForm.FinishBClick(Sender: TObject); var Page: TfrxReportPage; Band: TfrxBand; Memo: TfrxCustomMemoView; CurY, PageWidth, MaxHeaderWidth: Extended; Widths, HeaderWidths, DataWidths: array of Extended; function Duplicate(n: Integer): String; begin {$IFDEF Delphi12} Result := StringOfChar(Char('0'), n) {$ELSE} Result := ''; SetLength(Result, n); FillChar(Result[1], n, '0'); {$ENDIF} end; function CreateMemo(Parent: TfrxComponent): TfrxCustomMemoView; begin if FDotMatrix then Result := TfrxDMPMemoView.Create(Parent) else Result := TfrxMemoView.Create(Parent); if Parent <> nil then Result.CreateUniqueName; end; procedure CreatePage; begin Page := TfrxReportPage(FReport.Pages[0]); if PortraitRB.Checked then Page.Orientation := poPortrait else Page.Orientation := poLandscape; PageWidth := (Page.PaperWidth - Page.LeftMargin - Page.RightMargin) * 96 / 25.4; end; procedure CreateWidthsArray; var i, FieldsCount: Integer; HeaderMemo, DataMemo: TfrxCustomMemoView; MaxWidth, HeadersWidth, GapWidth: Extended; Style: TfrxStyles; begin FieldsCount := AvailableFieldsLB.Items.Count; SetLength(Widths, FieldsCount); SetLength(HeaderWidths, FieldsCount); SetLength(DataWidths, FieldsCount); HeaderMemo := CreateMemo(nil); DataMemo := CreateMemo(nil); if not FDotMatrix then begin Style := FStyleSheet.Find(StyleLB.Items[StyleLB.ItemIndex]); HeaderMemo.ApplyStyle(Style.Find('Header')); DataMemo.ApplyStyle(Style.Find('Data')); end; MaxWidth := 0; HeadersWidth := 0; MaxHeaderWidth := 0; GapWidth := 0; for i := 0 to FieldsCount - 1 do begin HeaderMemo.Text := AvailableFieldsLB.Items[i]; DataMemo.Text := Duplicate(FDataSet.DisplayWidth[AvailableFieldsLB.Items[i]]); HeaderWidths[i] := HeaderMemo.CalcWidth; DataWidths[i] := DataMemo.CalcWidth; if HeaderWidths[i] > DataWidths[i] then Widths[i] := HeaderWidths[i] else begin Widths[i] := DataWidths[i]; GapWidth := GapWidth + DataWidths[i] - HeaderWidths[i]; end; MaxWidth := MaxWidth + Widths[i]; HeadersWidth := HeadersWidth + HeaderWidths[i]; if HeaderWidths[i] > MaxHeaderWidth then MaxHeaderWidth := HeaderWidths[i]; end; if FitWidthCB.Checked and (MaxWidth > PageWidth) then begin if HeadersWidth > PageWidth then begin for i := 0 to FieldsCount - 1 do Widths[i] := HeaderWidths[i] / (HeadersWidth / PageWidth); end else begin for i := 0 to FieldsCount - 1 do if HeaderWidths[i] < DataWidths[i] then Widths[i] := Widths[i] - (DataWidths[i] - HeaderWidths[i]) / GapWidth * (MaxWidth - PageWidth); end; end; HeaderMemo.Free; DataMemo.Free; end; procedure CreateTitle; begin Band := TfrxReportTitle.Create(Page); Band.CreateUniqueName; Band.SetBounds(0, 0, 0, fr01cm * 7); CurY := 30; Memo := CreateMemo(Band); Memo.SetBounds(0, 0, 0, fr01cm * 6); Memo.Align := baWidth; Memo.HAlign := haCenter; Memo.VAlign := vaCenter; Memo.Text := 'Report'; Memo.Style := 'Title'; end; procedure CreateHeader; var i: Integer; X, Y: Extended; HeaderMemo: TfrxCustomMemoView; begin if ColumnarRB.Checked then Exit; Band := TfrxPageHeader.Create(Page); Band.CreateUniqueName; Band.SetBounds(0, CurY, 0, fr01cm * 7); HeaderMemo := CreateMemo(Band); HeaderMemo.SetBounds(0, 0, PageWidth, 0); HeaderMemo.Style := 'Header line'; X := 0; Y := 0; for i := 0 to AvailableFieldsLB.Items.Count - 1 do begin if X + Widths[i] > PageWidth + 1 then begin X := 0; Y := Y + fr01cm * 6; end; Memo := CreateMemo(Band); Memo.SetBounds(X, Y, Widths[i], fr01cm * 6); Memo.Text := AvailableFieldsLB.Items[i]; Memo.Style := 'Header'; X := X + Widths[i]; end; Band.Height := Y + fr01cm * 6; HeaderMemo.Height := Band.Height; if FDotMatrix then HeaderMemo.Free; CurY := CurY + Band.Height; end; procedure CreateGroupHeaders; var i: Integer; begin for i := 0 to GroupsLB.Items.Count - 1 do begin Band := TfrxGroupHeader.Create(Page); Band.CreateUniqueName; Band.SetBounds(0, CurY, 0, fr01cm * 7); TfrxGroupHeader(Band).Condition := FDataSet.UserName + '."' + GroupsLB.Items[i] + '"'; CurY := CurY + 30; Memo := CreateMemo(Band); Memo.SetBounds(0, 0, 0, fr01cm * 6); Memo.Align := baWidth; Memo.VAlign := vaCenter; Memo.DataSet := FDataSet; Memo.DataField := GroupsLB.Items[i]; Memo.Style := 'Group header'; end; end; procedure CreateData; var i: Integer; X, Y: Extended; begin Band := TfrxMasterData.Create(Page); Band.CreateUniqueName; Band.SetBounds(0, CurY, 0, 0); TfrxMasterData(Band).DataSet := FDataSet; CurY := CurY + 30; X := 0; Y := 0; for i := 0 to AvailableFieldsLB.Items.Count - 1 do begin if ColumnarRB.Checked then begin Memo := CreateMemo(Band); Memo.SetBounds(0, Y, MaxHeaderWidth, fr01cm * 5); Memo.Text := AvailableFieldsLB.Items[i]; Memo.Style := 'Header'; Memo := CreateMemo(Band); Memo.SetBounds(MaxHeaderWidth + fr01cm * 5, Y, DataWidths[i], fr01cm * 5); Memo.DataSet := FDataSet; Memo.DataField := AvailableFieldsLB.Items[i]; Memo.Style := 'Data'; Y := Y + fr01cm * 5; end else begin if X + Widths[i] > PageWidth + 1 then begin X := 0; Y := Y + fr01cm * 5; end; Memo := CreateMemo(Band); Memo.SetBounds(X, Y, Widths[i], fr01cm * 5); Memo.DataSet := FDataSet; Memo.DataField := AvailableFieldsLB.Items[i]; Memo.Style := 'Data'; X := X + Widths[i]; end; end; Band.Height := Y + fr01cm * 5; CurY := CurY + Band.Height; end; procedure CreateGroupFooters; var i: Integer; begin CurY := 1000; for i := GroupsLB.Items.Count - 1 downto 0 do begin Band := TfrxGroupFooter.Create(Page); Band.CreateUniqueName; Band.SetBounds(0, CurY, 0, 0); CurY := CurY - 30; end; end; procedure CreateFooter; begin Band := TfrxPageFooter.Create(Page); Band.CreateUniqueName; Band.SetBounds(0, 1000, 0, fr01cm * 7); Memo := CreateMemo(Band); Memo.Align := baWidth; Memo.Frame.Typ := [ftTop]; Memo.Frame.Width := 2; Memo := CreateMemo(Band); Memo.SetBounds(0, 1, 0, fr01cm * 6); Memo.AutoWidth := True; Memo.Text := '[Date] [Time]'; Memo := CreateMemo(Band); Memo.SetBounds(100, 1, fr1cm * 2, fr01cm * 6); Memo.Align := baRight; Memo.HAlign := haRight; Memo.Text := 'Page [Page#]'; end; begin try FDesigner.Lock; FReport.FileName := ''; FReport.DotMatrixReport := FDotMatrix; FReport.DataSets.Clear; if FDataset <> nil then FReport.DataSets.Add(FDataSet); CreatePage; CreateWidthsArray; CreateTitle; CreateHeader; CreateGroupHeaders; CreateData; CreateGroupFooters; CreateFooter; if not FDotMatrix then FReport.Styles := FStyleSheet.Find(StyleLB.Items[StyleLB.ItemIndex]); finally FDesigner.ReloadReport; Widths := nil; HeaderWidths := nil; DataWidths := nil; end; end; procedure TfrxStdWizardForm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if Key = VK_F1 then frxResources.Help(Self); end; initialization frxWizards.Register1(TfrxStdWizard, 1); frxWizards.Register1(TfrxStdEmptyWizard, 0); {$IFNDEF FR_LITE} frxWizards.Register1(TfrxDotMatrixWizard, 1); frxWizards.Register1(TfrxDMPEmptyWizard, 0); {$ENDIF} finalization frxWizards.Unregister(TfrxStdWizard); frxWizards.Unregister(TfrxStdEmptyWizard); {$IFNDEF FR_LITE} frxWizards.Unregister(TfrxDotMatrixWizard); frxWizards.Unregister(TfrxDMPEmptyWizard); {$ENDIF} end.