source: cprs/trunk/CPRS-Chart/Consults/fPreReq.pas@ 1672

Last change on this file since 1672 was 829, checked in by Kevin Toppenberg, 14 years ago

Upgrade to version 27

File size: 5.6 KB
RevLine 
[456]1unit fPreReq;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
[829]7 StdCtrls, ORFn, ComCtrls, ExtCtrls, fBase508Form, VA508AccessibilityManager,
8 uReports;
[456]9
10type
[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
30function DisplayPrerequisites(ReportText: TStrings; ReportTitle: string): Boolean;
31
32var
33 ContinueWithOrder: Boolean;
34
35implementation
36
37uses
[829]38 uCore, rCore, rReports, Printers, rMisc;
[456]39
40{$R *.DFM}
41
42function CreateReportBox(ReportText: TStrings; ReportTitle: string): TfrmPrerequisites;
43var
44 i, AWidth, MaxWidth, AHeight: Integer;
45 Rect: TRect;
46begin
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;
80end;
81
82function DisplayPrerequisites(ReportText: TStrings; ReportTitle: string): Boolean;
83var
84 frmPrerequisites: TfrmPrerequisites;
85begin
86 frmPrerequisites := CreateReportBox(ReportText, ReportTitle);
87 try
88 frmPrerequisites.ShowModal;
89 Result := ContinueWithOrder;
90 finally
91 frmPrerequisites.Release;
92 end;
93end;
94
95procedure TfrmPrerequisites.memReportClick(Sender: TObject);
96begin
97 //Close;
98end;
99
100procedure TfrmPrerequisites.cmdContinueClick(Sender: TObject);
101begin
102 ContinueWithOrder := True;
103 Close;
104end;
105
106procedure TfrmPrerequisites.cmdCancelClick(Sender: TObject);
107begin
108 ContinueWithOrder := False;
109 Close;
110end;
111
112procedure TfrmPrerequisites.cmdPrintClick(Sender: TObject);
113var
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
120const
121 PAGE_BREAK = '**PAGE BREAK**';
122begin
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;
168end;
169
170procedure TfrmPrerequisites.AlignButtons;
171Const
172 BtnSpace = 8;
173begin
[829]174 cmdCancel.Left := self.Width - cmdCancel.Width - (BtnSpace * 3) - 3;
[456]175 cmdContinue.Left := cmdCancel.Left - BtnSpace - cmdContinue.Width;
176end;
177
178procedure TfrmPrerequisites.FormClose(Sender: TObject;
179 var Action: TCloseAction);
180begin
181 SaveUserBounds(Self); //Save Position & Size of Form
182end;
183
[829]184procedure TfrmPrerequisites.FormCreate(Sender: TObject);
[456]185begin
[829]186 inherited;
187 ResizeAnchoredFormToFont(Self);
[456]188 SetFormPosition(Self); //Get Saved Position & Size of Form
189end;
190
[829]191procedure TfrmPrerequisites.OnActivate(Sender: TObject);
192begin
193 if Self.VertScrollBar.IsScrollBarVisible then Self.VertScrollBar.Position := 0;
194end;
[456]195end.
Note: See TracBrowser for help on using the repository browser.