[456] | 1 | unit fPreReq;
|
---|
| 2 |
|
---|
| 3 | interface
|
---|
| 4 |
|
---|
| 5 | uses
|
---|
| 6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
[829] | 7 | StdCtrls, ORFn, ComCtrls, ExtCtrls, fBase508Form, VA508AccessibilityManager,
|
---|
| 8 | uReports;
|
---|
[456] | 9 |
|
---|
| 10 | type
|
---|
[829] | 11 | TfrmPrerequisites = class(TfrmBase508Form)
|
---|
[456] | 12 | lblFontTest: TLabel;
|
---|
| 13 | memReport: TRichEdit;
|
---|
| 14 | pnlButton: TPanel;
|
---|
| 15 | cmdContinue: TButton;
|
---|
| 16 | cmdCancel: TButton;
|
---|
| 17 | cmdPrint: TButton;
|
---|
| 18 | dlgPrintReport: TPrintDialog;
|
---|
| 19 | procedure memReportClick(Sender: TObject);
|
---|
| 20 | procedure cmdContinueClick(Sender: TObject);
|
---|
| 21 | procedure cmdCancelClick(Sender: TObject);
|
---|
| 22 | procedure cmdPrintClick(Sender: TObject);
|
---|
[829] | 23 | procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
| 24 | procedure OnActivate(Sender: TObject);
|
---|
[456] | 25 | procedure FormCreate(Sender: TObject);
|
---|
| 26 | private
|
---|
| 27 | procedure AlignButtons();
|
---|
| 28 | end;
|
---|
| 29 |
|
---|
| 30 | function DisplayPrerequisites(ReportText: TStrings; ReportTitle: string): Boolean;
|
---|
| 31 |
|
---|
| 32 | var
|
---|
| 33 | ContinueWithOrder: Boolean;
|
---|
| 34 |
|
---|
| 35 | implementation
|
---|
| 36 |
|
---|
| 37 | uses
|
---|
[829] | 38 | uCore, rCore, rReports, Printers, rMisc;
|
---|
[456] | 39 |
|
---|
| 40 | {$R *.DFM}
|
---|
| 41 |
|
---|
| 42 | function CreateReportBox(ReportText: TStrings; ReportTitle: string): TfrmPrerequisites;
|
---|
| 43 | var
|
---|
| 44 | i, AWidth, MaxWidth, AHeight: Integer;
|
---|
| 45 | Rect: TRect;
|
---|
| 46 | begin
|
---|
| 47 | Result := TfrmPrerequisites.Create(Application);
|
---|
| 48 | try
|
---|
| 49 | with Result do
|
---|
| 50 | begin
|
---|
| 51 | MaxWidth := PnlButton.Width;
|
---|
| 52 | for i := 0 to ReportText.Count - 1 do
|
---|
| 53 | begin
|
---|
| 54 | AWidth := lblFontTest.Canvas.TextWidth(ReportText[i]);
|
---|
| 55 | if AWidth > MaxWidth then MaxWidth := AWidth;
|
---|
| 56 | end;
|
---|
| 57 | MaxWidth := MaxWidth + (GetSystemMetrics(SM_CXFRAME) * 2) + GetSystemMetrics(SM_CXVSCROLL);
|
---|
| 58 | AHeight := (ReportText.Count * lblFontTest.Height) + ReportText.Count +
|
---|
| 59 | (GetSystemMetrics(SM_CYFRAME) * 3) + GetSystemMetrics(SM_CYCAPTION);
|
---|
| 60 | AHeight := AHeight + pnlbutton.Height;
|
---|
| 61 | AHeight := HigherOf(AHeight, 250);
|
---|
| 62 | if AHeight > (Screen.Height - 60) then AHeight := Screen.Height - 60;
|
---|
| 63 | if MaxWidth > Screen.Width then MaxWidth := Screen.Width;
|
---|
| 64 | Width := MaxWidth;
|
---|
| 65 | Height := AHeight;
|
---|
| 66 | Rect := BoundsRect;
|
---|
| 67 | ForceInsideWorkArea(Rect);
|
---|
| 68 | BoundsRect := Rect;
|
---|
[829] | 69 | QuickCopy(ReportText, memReport);
|
---|
[456] | 70 | //Quick fix to work around glich in resize algorithim
|
---|
| 71 | AlignButtons();
|
---|
| 72 | for i := 1 to Length(ReportTitle) do if ReportTitle[i] = #9 then ReportTitle[i] := ' ';
|
---|
| 73 | Caption := ReportTitle;
|
---|
| 74 | memReport.SelStart := 0;
|
---|
| 75 | end;
|
---|
| 76 | except
|
---|
| 77 | KillObj(@Result);
|
---|
| 78 | raise;
|
---|
| 79 | end;
|
---|
| 80 | end;
|
---|
| 81 |
|
---|
| 82 | function DisplayPrerequisites(ReportText: TStrings; ReportTitle: string): Boolean;
|
---|
| 83 | var
|
---|
| 84 | frmPrerequisites: TfrmPrerequisites;
|
---|
| 85 | begin
|
---|
| 86 | frmPrerequisites := CreateReportBox(ReportText, ReportTitle);
|
---|
| 87 | try
|
---|
| 88 | frmPrerequisites.ShowModal;
|
---|
| 89 | Result := ContinueWithOrder;
|
---|
| 90 | finally
|
---|
| 91 | frmPrerequisites.Release;
|
---|
| 92 | end;
|
---|
| 93 | end;
|
---|
| 94 |
|
---|
| 95 | procedure TfrmPrerequisites.memReportClick(Sender: TObject);
|
---|
| 96 | begin
|
---|
| 97 | //Close;
|
---|
| 98 | end;
|
---|
| 99 |
|
---|
| 100 | procedure TfrmPrerequisites.cmdContinueClick(Sender: TObject);
|
---|
| 101 | begin
|
---|
| 102 | ContinueWithOrder := True;
|
---|
| 103 | Close;
|
---|
| 104 | end;
|
---|
| 105 |
|
---|
| 106 | procedure TfrmPrerequisites.cmdCancelClick(Sender: TObject);
|
---|
| 107 | begin
|
---|
| 108 | ContinueWithOrder := False;
|
---|
| 109 | Close;
|
---|
| 110 | end;
|
---|
| 111 |
|
---|
| 112 | procedure TfrmPrerequisites.cmdPrintClick(Sender: TObject);
|
---|
| 113 | var
|
---|
| 114 | AHeader: TStringList;
|
---|
| 115 | memPrintReport: TRichEdit;
|
---|
| 116 | MaxLines, LastLine, ThisPage, i: integer;
|
---|
| 117 | ErrMsg: string;
|
---|
| 118 | RemoteSiteID: string; //for Remote site printing
|
---|
| 119 | RemoteQuery: string; //for Remote site printing
|
---|
| 120 | const
|
---|
| 121 | PAGE_BREAK = '**PAGE BREAK**';
|
---|
| 122 | begin
|
---|
| 123 | RemoteSiteID := '';
|
---|
| 124 | RemoteQuery := '';
|
---|
| 125 | if dlgPrintReport.Execute then
|
---|
| 126 | begin
|
---|
| 127 | AHeader := TStringList.Create;
|
---|
| 128 | CreatePatientHeader(AHeader, Self.Caption);
|
---|
[829] | 129 | memPrintReport := CreateReportTextComponent(Self);
|
---|
[456] | 130 | try
|
---|
| 131 | MaxLines := 60 - AHeader.Count;
|
---|
| 132 | LastLine := 0;
|
---|
| 133 | ThisPage := 0;
|
---|
| 134 | with memPrintReport do
|
---|
| 135 | begin
|
---|
| 136 | repeat
|
---|
| 137 | with Lines do
|
---|
| 138 | begin
|
---|
| 139 | AddStrings(AHeader);
|
---|
| 140 | for i := 0 to MaxLines do
|
---|
| 141 | if i < memReport.Lines.Count then
|
---|
| 142 | Add(memReport.Lines[LastLine + i])
|
---|
| 143 | else
|
---|
| 144 | Break;
|
---|
| 145 | LastLine := LastLine + i;
|
---|
| 146 | Add(' ');
|
---|
| 147 | Add(' ');
|
---|
| 148 | Add(StringOfChar('-', 74));
|
---|
| 149 | if LastLine >= memReport.Lines.Count - 1 then
|
---|
| 150 | Add('End of report')
|
---|
| 151 | else
|
---|
| 152 | begin
|
---|
| 153 | ThisPage := ThisPage + 1;
|
---|
| 154 | Add('Page ' + IntToStr(ThisPage));
|
---|
| 155 | Add(PAGE_BREAK);
|
---|
| 156 | end;
|
---|
| 157 | end;
|
---|
| 158 | until LastLine >= memReport.Lines.Count - 1;
|
---|
| 159 | PrintWindowsReport(memPrintReport, PAGE_BREAK, Self.Caption, ErrMsg);
|
---|
| 160 | end;
|
---|
| 161 | finally
|
---|
| 162 | memPrintReport.Free;
|
---|
| 163 | AHeader.Free;
|
---|
| 164 | end;
|
---|
| 165 | end;
|
---|
| 166 | memReport.SelStart := 0;
|
---|
| 167 | memReport.Invalidate;
|
---|
| 168 | end;
|
---|
| 169 |
|
---|
| 170 | procedure TfrmPrerequisites.AlignButtons;
|
---|
| 171 | Const
|
---|
| 172 | BtnSpace = 8;
|
---|
| 173 | begin
|
---|
[829] | 174 | cmdCancel.Left := self.Width - cmdCancel.Width - (BtnSpace * 3) - 3;
|
---|
[456] | 175 | cmdContinue.Left := cmdCancel.Left - BtnSpace - cmdContinue.Width;
|
---|
| 176 | end;
|
---|
| 177 |
|
---|
| 178 | procedure TfrmPrerequisites.FormClose(Sender: TObject;
|
---|
| 179 | var Action: TCloseAction);
|
---|
| 180 | begin
|
---|
| 181 | SaveUserBounds(Self); //Save Position & Size of Form
|
---|
| 182 | end;
|
---|
| 183 |
|
---|
[829] | 184 | procedure TfrmPrerequisites.FormCreate(Sender: TObject);
|
---|
[456] | 185 | begin
|
---|
[829] | 186 | inherited;
|
---|
| 187 | ResizeAnchoredFormToFont(Self);
|
---|
[456] | 188 | SetFormPosition(Self); //Get Saved Position & Size of Form
|
---|
| 189 | end;
|
---|
| 190 |
|
---|
[829] | 191 | procedure TfrmPrerequisites.OnActivate(Sender: TObject);
|
---|
| 192 | begin
|
---|
| 193 | if Self.VertScrollBar.IsScrollBarVisible then Self.VertScrollBar.Position := 0;
|
---|
| 194 | end;
|
---|
[456] | 195 | end.
|
---|