source: cprs/branches/foia-cprs/CPRS-Chart/Templates/fTemplateView.pas

Last change on this file was 459, checked in by Kevin Toppenberg, 16 years ago

Adding foia-cprs branch

File size: 3.4 KB
Line 
1unit fTemplateView;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 StdCtrls, ComCtrls, ExtCtrls, Menus, ORFn;
8
9type
10 TfrmTemplateView = class(TForm)
11 pnlBottom: TPanel;
12 reMain: TRichEdit;
13 btnClose: TButton;
14 cbStayOnTop: TCheckBox;
15 popView: TPopupMenu;
16 Copy1: TMenuItem;
17 N1: TMenuItem;
18 SelectAll1: TMenuItem;
19 btnPrint: TButton;
20 procedure btnCloseClick(Sender: TObject);
21 procedure FormClose(Sender: TObject; var Action: TCloseAction);
22 procedure cbStayOnTopClick(Sender: TObject);
23 procedure FormDestroy(Sender: TObject);
24 procedure popViewPopup(Sender: TObject);
25 procedure Copy1Click(Sender: TObject);
26 procedure SelectAll1Click(Sender: TObject);
27 procedure btnPrintClick(Sender: TObject);
28 procedure FormCreate(Sender: TObject);
29 procedure FormShow(Sender: TObject);
30 private
31 end;
32
33procedure ShowTemplateData(Form: TForm; const Title, Text: string);
34
35var
36 frmTemplateView: TfrmTemplateView = nil;
37
38implementation
39
40uses fTemplateDialog, fRptBox, rMisc;
41
42{$R *.DFM}
43
44var
45 LastStayOnTop: boolean = FALSE;
46
47procedure ShowTemplateData(Form: TForm; const Title, Text: string);
48var
49 Cnt: integer;
50
51begin
52 if(not assigned(frmTemplateView)) then
53 frmTemplateView := TfrmTemplateView.Create(Application);
54 ResizeAnchoredFormToFont(frmTemplateView);
55 frmTemplateView.reMain.Lines.Clear;
56 frmTemplateView.Caption := 'Template: ' + Title;
57 frmTemplateView.reMain.Lines.Text := Text;
58 Cnt := frmTemplateView.reMain.Lines.Count;
59 CheckBoilerplate4Fields(frmTemplateView.reMain.Lines, frmTemplateView.Caption, TRUE);
60 if (Cnt > 0) and (frmTemplateView.reMain.Lines.Count = 0) then
61 frmTemplateView.Close
62 else
63 begin
64 frmTemplateView.cbStayOnTop.Checked := LastStayOnTop;
65 frmTemplateView.ActiveControl := frmTemplateView.btnClose;
66 frmTemplateView.Show;
67 Application.ProcessMessages;
68 SendMessage(frmTemplateView.reMain.Handle, EM_LINESCROLL, 0, -1 * frmTemplateView.reMain.Lines.Count);
69 end;
70end;
71
72procedure TfrmTemplateView.btnCloseClick(Sender: TObject);
73begin
74 Close;
75end;
76
77procedure TfrmTemplateView.FormClose(Sender: TObject;
78 var Action: TCloseAction);
79begin
80 SaveUserBounds(frmTemplateView);
81 Action := caFree;
82end;
83
84procedure TfrmTemplateView.cbStayOnTopClick(Sender: TObject);
85begin
86 if(cbStayOnTop.Checked) then
87 FormStyle := fsStayOnTop
88 else
89 FormStyle := fsNormal;
90 if(LastStayOnTop <> cbStayOnTop.Checked) then
91 LastStayOnTop := cbStayOnTop.Checked;
92end;
93
94procedure TfrmTemplateView.FormDestroy(Sender: TObject);
95begin
96 frmTemplateView := nil;
97end;
98
99procedure TfrmTemplateView.popViewPopup(Sender: TObject);
100begin
101 Copy1.Enabled := (reMain.SelLength > 0);
102 SelectAll1.Enabled := (reMain.Lines.Count > 0);
103end;
104
105procedure TfrmTemplateView.Copy1Click(Sender: TObject);
106begin
107 reMain.CopyToClipboard;
108end;
109
110procedure TfrmTemplateView.SelectAll1Click(Sender: TObject);
111begin
112 reMain.SelectAll;
113end;
114
115procedure TfrmTemplateView.btnPrintClick(Sender: TObject);
116begin
117 PrintStrings(Self, reMain.Lines, Caption, 'End of template');
118end;
119
120procedure TfrmTemplateView.FormCreate(Sender: TObject);
121begin
122 reMain.Color := ReadOnlyColor;
123end;
124
125procedure TfrmTemplateView.FormShow(Sender: TObject);
126begin
127 SetFormPosition(frmTemplateView);
128end;
129
130end.
Note: See TracBrowser for help on using the repository browser.