source: cprs/branches/tmg-cprs/CPRS-Chart/Options/fOptionsNotes.pas@ 1623

Last change on this file since 1623 was 686, checked in by Kevin Toppenberg, 15 years ago

Fixed HTML Linked Template-Note Issue

File size: 10.6 KB
RevLine 
[453]1//kt -- Modified with SourceScanner on 8/8/2007
2unit fOptionsNotes;
3
4interface
5
[541]6{ //kt 8/09 The following objects were addeded to the *FORM* of this unit
7
8 object lblHTMLViewSize: TLabel
9 Left = 8
10 Top = 144
11 Width = 159
12 Height = 13
13 Caption = 'Formatted Text (HTML) View Size'
14 end
15 object cboHTMLViewSize: TComboBox
16 Left = 8
17 Top = 162
18 Width = 153
19 Height = 21
20 ItemHeight = 13
21 TabOrder = 6
22 Text = '<View Size>'
23 OnClick = cboHTMLViewSizeClick
24 Items.Strings = (
25 'Smallest'
26 'Small'
27 'Medium'
28 'Large'
29 'Largest')
30 end
31 object cbDefaultHTMLMode: TCheckBox
32 Left = 8
33 Top = 112
34 Width = 225
35 Height = 17
36 Caption = 'Start notes in Formatted (HTML) Mode'
37 TabOrder = 7
38 OnClick = cbDefaultHTMLModeClick
39}
40
41
[453]42uses
43 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
[541]44 IniFiles, //kt for IniFile
[453]45 StdCtrls, ExtCtrls, ORCtrls, ORFn, ComCtrls, DKLang;
46
47type
48 TfrmOptionsNotes = class(TForm)
49 lblAutoSave1: TLabel;
50 lblCosigner: TLabel;
51 txtAutoSave: TCaptionEdit;
52 spnAutoSave: TUpDown;
53 chkVerifyNote: TCheckBox;
54 chkAskSubject: TCheckBox;
55 cboCosigner: TORComboBox;
56 pnlBottom: TPanel;
57 bvlBottom: TBevel;
58 btnOK: TButton;
59 btnCancel: TButton;
60 lblAutoSave2: TLabel;
[541]61 cboHTMLViewSize: TComboBox; //kt 8/09
62 lblHTMLViewSize: TLabel; //kt 8/09
63 cbDefaultHTMLMode: TCheckBox; //kt 8/09
64 DKLanguageController1: TDKLanguageController; //kt
[453]65 procedure FormShow(Sender: TObject);
66 procedure btnOKClick(Sender: TObject);
67 procedure txtAutoSaveChange(Sender: TObject);
68 procedure txtAutoSaveKeyPress(Sender: TObject; var Key: Char);
69 procedure txtAutoSaveExit(Sender: TObject);
70 procedure spnAutoSaveClick(Sender: TObject; Button: TUDBtnType);
71 procedure cboCosignerNeedData(Sender: TObject; const StartFrom: String;
72 Direction, InsertAt: Integer);
73 procedure cboCosignerExit(Sender: TObject);
[541]74 procedure FormCreate(Sender: TObject); //kt 8/09
75 procedure cbDefaultHTMLModeClick(Sender: TObject); //kt 8/09
76 procedure cboHTMLViewSizeChange(Sender: TObject); //kt 8/09
[453]77 private
78 { Private declarations }
79 public
80 { Public declarations }
81 end;
82
83var
84 frmOptionsNotes: TfrmOptionsNotes;
[541]85 OptionsNotesIniFile : TIniFile; //kt 8/09
86 DefaultEditHTMLMode : boolean; //kt 8/09
87 FHTMLEditTextSize : integer; //kt 8/09
[453]88
89procedure DialogOptionsNotes(topvalue, leftvalue, fontsize: integer; var actiontype: Integer);
[541]90procedure SetDefaultEditHTMLMode(Value : boolean); //kt 8/09
91procedure Loaded; //kt 8/09
[453]92
93implementation
94
95{$R *.DFM}
96
97uses
[541]98 uCore, //kt 8/09
99 Registry, //kt 8/09
[686]100 rOptions, uOptions, rCore, rTIU, rDCSumm, uTemplates;
[453]101
[541]102const
103 DEFAULT_HTML_EDIT_MODE = 'Edit-in-HTML default mode'; //kt 8/09
104 DEFAULT_HTML_TEXT_SIZE = 'Edit-in-HTML default text size'; //kt 8/09
105
106procedure SetRegHTMLViewSize(Size : integer); forward; //kt 8/09
107
[453]108procedure DialogOptionsNotes(topvalue, leftvalue, fontsize: integer; var actiontype: Integer);
109// create the form and make it modal, return an action
110var
111 frmOptionsNotes: TfrmOptionsNotes;
112begin
113 frmOptionsNotes := TfrmOptionsNotes.Create(Application);
114 actiontype := 0;
115 try
116 with frmOptionsNotes do
117 begin
118 if (topvalue < 0) or (leftvalue < 0) then
119 Position := poScreenCenter
120 else
121 begin
122 Position := poDesigned;
123 Top := topvalue;
124 Left := leftvalue;
125 end;
126 ResizeAnchoredFormToFont(frmOptionsNotes);
127 ShowModal;
128 actiontype := btnOK.Tag;
129 end;
130 finally
131 frmOptionsNotes.Release;
132 end;
133end;
134
135procedure TfrmOptionsNotes.FormShow(Sender: TObject);
136// displays defaults
137// opening tab^use last tab^autosave seconds^verify note title
138var
139 autosave, verify: integer;
140 cosigner: Int64;
141 values, cosignername: string;
142begin
143 values := rpcGetOther;
144 autosave := strtointdef(Piece(values, '^', 3), -1);
145 verify := strtointdef(Piece(values, '^', 4), 0);
146 chkVerifyNote.Checked := verify = 1;
147 chkVerifyNote.Tag := verify;
148 spnAutoSave.Position := autosave;
149 spnAutoSave.Tag := autosave;
150
151 values := rpcGetDefaultCosigner;
152 cosigner := strtoint64def(Piece(values, '^', 1), 0);
153 cosignername := Piece(values, '^', 2);
154 cboCosigner.Items.Add('0^<none>');
155 cboCosigner.InitLongList(cosignername);
156 cboCosigner.SelectByIEN(cosigner);
157 cboCosigner.Tag := cosigner;
158 chkAskSubject.Checked := rpcGetSubject;
159 if chkAskSubject.Checked then chkAskSubject.Tag := 1;
[541]160 cbDefaultHTMLMode.Checked := DefaultEditHTMLMode; //kt
[453]161end;
162
163procedure TfrmOptionsNotes.btnOKClick(Sender: TObject);
164// only saves values if they have been changed
165// opening tab^use last tab^autosave seconds^verify note title
166var
167 values: string;
168begin
169 values := '';
170 values := values + '^';
171 values := values + '^';
172 if spnAutoSave.Position <> spnAutoSave.Tag then
173 values := values + inttostr(spnAutoSave.Position);
174 values := values + '^';
175 if chkVerifyNote.Checked then
176 if chkVerifyNote.Tag <> 1 then
177 values := values + '1';
178 if not chkVerifyNote.Checked then
179 if chkVerifyNote.Tag <> 0 then
180 values := values + '0';
181 rpcSetOther(values);
182 with chkAskSubject do
183 if (Checked and (Tag = 0)) or (not Checked and (Tag = 1)) then
184 rpcSetSubject(Checked);
185 with cboCosigner do
186 if Tag <> ItemIEN then
187 rpcSetDefaultCosigner(ItemIEN);
188 ResetTIUPreferences;
189 ResetDCSummPreferences;
190end;
191
192procedure TfrmOptionsNotes.txtAutoSaveChange(Sender: TObject);
193var
194 maxvalue: integer;
195begin
196 maxvalue := spnAutoSave.Max;
197 with txtAutoSave do
198 begin
199 if strtointdef(Text, maxvalue) > maxvalue then
200 begin
201 beep;
202// InfoBox('Number must be < ' + inttostr(maxvalue), 'Warning', MB_OK or MB_ICONWARNING); <-- original line. //kt 8/8/2007
203 InfoBox(DKLangConstW('fOptionsNotes_Number_must_be_x')+' ' + inttostr(maxvalue), DKLangConstW('fOptionsNotes_Warning'), MB_OK or MB_ICONWARNING); //kt added 8/8/2007
204 if strtointdef(Text, 0) > maxvalue then
205 Text := inttostr(maxvalue);
206 end;
207 end;
208 spnAutoSaveClick(self, btNext);
209end;
210
211procedure TfrmOptionsNotes.txtAutoSaveKeyPress(Sender: TObject;
212 var Key: Char);
213begin
214 if Key = #13 then
215 begin
216 Perform(WM_NextDlgCtl, 0, 0);
217 exit;
218 end;
219 if not (Key in ['0'..'9', #8]) then
220 begin
221 Key := #0;
222 beep;
223 end;
224end;
225
226procedure TfrmOptionsNotes.txtAutoSaveExit(Sender: TObject);
227begin
228 with txtAutoSave do
229 begin
230 if Text = '' then
231 begin
232 Text := '0';
233 spnAutoSaveClick(self, btNext);
234 end
235 else if (Copy(Text, 1, 1) = '0') and (length(Text) > 1) then
236 begin
237 Text := inttostr(strtointdef(Text, 0));
238 spnAutoSaveClick(self, btNext);
239 end;
240 end;
241end;
242
243procedure TfrmOptionsNotes.spnAutoSaveClick(Sender: TObject;
244 Button: TUDBtnType);
245begin
246 txtAutoSave.SetFocus;
247 txtAutoSave.Tag := strtointdef(txtAutoSave.Text, 0);
248end;
249
250procedure TfrmOptionsNotes.cboCosignerNeedData(Sender: TObject;
251 const StartFrom: String; Direction, InsertAt: Integer);
252begin
253 cboCosigner.ForDataUse(rpcGetCosigners(StartFrom, Direction));
254end;
255
256procedure TfrmOptionsNotes.cboCosignerExit(Sender: TObject);
257begin
258 with cboCosigner do
259 if (Text = '') or (ItemIndex = -1) then
260 begin
261 ItemIndex := 0;
262 Text := DisplayText[0];
263 end;
264end;
265
[541]266
267procedure SetRegHTMLViewSize(Size : integer);
268//kt added entire function 8/09
269//NOTE: The only way to affect the view size of the HTML renderer (IE) is to
270// change a system-wide setting in the registry. Then CPRS has to be
271// restarted for changes to take effect.
272var
273 FontSizeData : array[0..3] of byte;
274 ZoomReg : TRegistry;
275begin
276 if (Size < 0) or (Size > 255) then exit;
277 ZoomReg := TRegistry.Create;
278 FontSizeData[0] := Lo(Size); FontSizeData[1] := 0; FontSizeData[2] := 0; FontSizeData[3] := 0;
279 try
280 ZoomReg.Rootkey := HKEY_CURRENT_USER;
281 if ZoomReg.OpenKey('\Software\Microsoft\Internet Explorer\International\Scripts\3', False) then begin
282 ZoomReg.WriteBinaryData('IEFontSize',FontSizeData,SizeOf(FontSizeData));
283 end;
284 finally
285 ZoomReg.Free;
286 end;
287end;
288
289procedure SetDefaultEditHTMLMode(Value : boolean);
290//kt added entire function 8/09
291begin
292 if Value <> DefaultEditHTMLMode then begin
[657]293 if OptionsNotesIniFile = nil then begin
294 OptionsNotesIniFile := TIniFile.Create(ChangeFileExt(Application.ExeName, '.INI')); //kt
295 OptionsNotesIniFile.WriteBool(User.Name,DEFAULT_HTML_EDIT_MODE,Value);
296 DefaultEditHTMLMode := Value;
297 OptionsNotesIniFile.Free;
298 OptionsNotesIniFile := nil;
299 end else begin
300 OptionsNotesIniFile.WriteBool(User.Name,DEFAULT_HTML_EDIT_MODE,Value);
301 DefaultEditHTMLMode := Value;
302 end;
[541]303 end;
[686]304 uTemplates.bUsingHTMLMode := Value; //test line //elh
[541]305end;
306
307procedure TfrmOptionsNotes.cbDefaultHTMLModeClick(Sender: TObject);
308//kt added entire function 8/09
309begin
310 SetDefaultEditHTMLMode(cbDefaultHTMLMode.Checked);
311end;
312
313procedure TfrmOptionsNotes.cboHTMLViewSizeChange(Sender: TObject);
314//kt added entire function 8/09
315begin
316 SetRegHTMLViewSize(cboHTMLViewSize.ItemIndex);
317 OptionsNotesIniFile.WriteInteger(User.Name,DEFAULT_HTML_TEXT_SIZE,cboHTMLViewSize.ItemIndex);
318 MessageDlg('Formated text size change will take '+#10+#13+
319 'effect next time CPRS is restarted.',mtInformation,[mbOK],0);
320end;
321
322procedure Loaded;
323//kt added entire function 8/09
324begin
325 //Code was put in global access space because object is not instantiated until
326 //after user shows options (which could be never)
327 OptionsNotesIniFile := TIniFile.Create(ChangeFileExt(Application.ExeName, '.INI')); //kt
328 DefaultEditHTMLMode := OptionsNotesIniFile.ReadBool(User.Name,DEFAULT_HTML_EDIT_MODE,false);
329 FHTMLEditTextSize := OptionsNotesIniFile.ReadInteger(User.Name,DEFAULT_HTML_TEXT_SIZE,2);
330 SetRegHTMLViewSize(FHTMLEditTextSize);
331end;
332
333procedure TfrmOptionsNotes.FormCreate(Sender: TObject);
334//kt added entire function 8/09
335//NOTE: form is not created until first time needed.
336begin
337 //NOTE: FHTMLEditTextSize is set in Loaded function (has to be called after sign on (so User.Name is available)
338 if (FHTMLEditTextSize > -1) and (FHTMLEditTextSize < cboHTMLViewSize.Items.Count) then begin
339 cboHTMLViewSize.ItemIndex := FHTMLEditTextSize;
340 cboHTMLViewSize.Text := cboHTMLViewSize.Items[FHTMLEditTextSize];
341 SetRegHTMLViewSize(cboHTMLViewSize.ItemIndex);
342 end;
343end;
344
345initialization
346
347finalization
348 OptionsNotesIniFile.Free; //kt 8/09
349
[453]350end.
Note: See TracBrowser for help on using the repository browser.