1 | unit fPtSelMsg;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
7 | ExtCtrls, StdCtrls, ComCtrls;
|
---|
8 |
|
---|
9 | type
|
---|
10 | TfrmPtSelMsg = class(TForm)
|
---|
11 | cmdClose: TButton;
|
---|
12 | timClose: TTimer;
|
---|
13 | memMessages: TRichEdit;
|
---|
14 | procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
15 | procedure cmdCloseClick(Sender: TObject);
|
---|
16 | procedure timCloseTimer(Sender: TObject);
|
---|
17 | procedure FormCreate(Sender: TObject);
|
---|
18 | procedure FormDestroy(Sender: TObject);
|
---|
19 | private
|
---|
20 | FSeconds: Integer;
|
---|
21 | FChanging: boolean;
|
---|
22 | FEventsActive: boolean;
|
---|
23 | FOldActiveFormChanged: TNotifyEvent;
|
---|
24 | FOldTabChanged: TNotifyEvent;
|
---|
25 | procedure ClearEvents;
|
---|
26 | procedure TabChanged(Sender: TObject);
|
---|
27 | procedure ActiveFormChanged(Sender: TObject);
|
---|
28 | public
|
---|
29 | { Public declarations }
|
---|
30 | end;
|
---|
31 |
|
---|
32 | procedure ShowPatientSelectMessages(const AMsg: string);
|
---|
33 | procedure HidePatientSelectMessages;
|
---|
34 |
|
---|
35 | implementation
|
---|
36 |
|
---|
37 | {$R *.DFM}
|
---|
38 |
|
---|
39 | uses ORFn, uCore, fFrame;
|
---|
40 |
|
---|
41 | var
|
---|
42 | frmPtSelMsg: TfrmPtSelMsg = nil;
|
---|
43 |
|
---|
44 | procedure ShowPatientSelectMessages(const AMsg: string);
|
---|
45 | begin
|
---|
46 | if assigned(frmPtSelMsg) then
|
---|
47 | begin
|
---|
48 | frmPtSelMsg.Free;
|
---|
49 | frmPtSelMsg := nil;
|
---|
50 | end;
|
---|
51 | if Length(AMsg) = 0 then Exit;
|
---|
52 | frmPtSelMsg := TfrmPtSelMsg.Create(Application);
|
---|
53 | ResizeAnchoredFormToFont(frmPtSelMsg);
|
---|
54 | frmPtSelMsg.memMessages.Lines.SetText(PChar(AMsg)); // Text := AMsg doesn't seem to work
|
---|
55 | frmPtSelMsg.memMessages.SelStart := 0;
|
---|
56 | if User.PtMsgHang = 0
|
---|
57 | then frmPtSelMsg.timClose.Enabled := False
|
---|
58 | else
|
---|
59 | begin
|
---|
60 | //frmPtSelMsg.timClose.Interval := User.PtMsgHang * 1000;
|
---|
61 | frmPtSelMsg.FSeconds := User.PtMsgHang;
|
---|
62 | frmPtSelMsg.timClose.Enabled := True;
|
---|
63 | end;
|
---|
64 | frmPtSelMsg.Show;
|
---|
65 | end;
|
---|
66 |
|
---|
67 | procedure HidePatientSelectMessages;
|
---|
68 | begin
|
---|
69 | if assigned(frmPtSelMsg) then
|
---|
70 | begin
|
---|
71 | frmPtSelMsg.Free;
|
---|
72 | frmPtSelMsg := nil;
|
---|
73 | end;
|
---|
74 | end;
|
---|
75 |
|
---|
76 | procedure TfrmPtSelMsg.timCloseTimer(Sender: TObject);
|
---|
77 | begin
|
---|
78 | Dec(FSeconds);
|
---|
79 | if FSeconds > 0
|
---|
80 | then Caption := 'Patient Lookup Messages (Auto-Close in ' + IntToStr(FSeconds) + ' seconds)'
|
---|
81 | else Close;
|
---|
82 | end;
|
---|
83 |
|
---|
84 | procedure TfrmPtSelMsg.cmdCloseClick(Sender: TObject);
|
---|
85 | begin
|
---|
86 | Close;
|
---|
87 | end;
|
---|
88 |
|
---|
89 | procedure TfrmPtSelMsg.FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
90 | begin
|
---|
91 | Action := caFree;
|
---|
92 | end;
|
---|
93 |
|
---|
94 | procedure TfrmPtSelMsg.FormCreate(Sender: TObject);
|
---|
95 | begin
|
---|
96 | memMessages.Color := ReadOnlyColor;
|
---|
97 | FOldActiveFormChanged := Screen.OnActiveFormChange;
|
---|
98 | Screen.OnActiveFormChange := ActiveFormChanged;
|
---|
99 | FOldTabChanged := frmFrame.OnTabChanged;
|
---|
100 | frmFrame.OnTabChanged := TabChanged;
|
---|
101 | FEventsActive := TRUE;
|
---|
102 | end;
|
---|
103 |
|
---|
104 | procedure TfrmPtSelMsg.FormDestroy(Sender: TObject);
|
---|
105 | begin
|
---|
106 | ClearEvents;
|
---|
107 | frmPtSelMsg := nil;
|
---|
108 | end;
|
---|
109 |
|
---|
110 | procedure TfrmPtSelMsg.ActiveFormChanged(Sender: TObject);
|
---|
111 | begin
|
---|
112 | if assigned(FOldActiveFormChanged) then
|
---|
113 | FOldActiveFormChanged(Sender);
|
---|
114 | if (not FChanging) and (Screen.ActiveForm <> Self) and
|
---|
115 | (not (csDestroying in Self.ComponentState)) then
|
---|
116 | begin
|
---|
117 | FChanging := TRUE;
|
---|
118 | try
|
---|
119 | SetFocus;
|
---|
120 | finally
|
---|
121 | FChanging := FALSE;
|
---|
122 | end;
|
---|
123 | end;
|
---|
124 | end;
|
---|
125 |
|
---|
126 | procedure TfrmPtSelMsg.ClearEvents;
|
---|
127 | begin
|
---|
128 | if FEventsActive then
|
---|
129 | begin
|
---|
130 | Screen.OnActiveFormChange := FOldActiveFormChanged;
|
---|
131 | frmFrame.OnTabChanged := FOldTabChanged;
|
---|
132 | FEventsActive := FALSE;
|
---|
133 | end;
|
---|
134 | end;
|
---|
135 |
|
---|
136 | procedure TfrmPtSelMsg.TabChanged(Sender: TObject);
|
---|
137 | begin
|
---|
138 | if assigned(FOldTabChanged) then
|
---|
139 | FOldTabChanged(Sender);
|
---|
140 | ClearEvents;
|
---|
141 | end;
|
---|
142 |
|
---|
143 | end.
|
---|