[453] | 1 | //kt -- Modified with SourceScanner on 8/8/2007
|
---|
| 2 | unit fOptionsNotes;
|
---|
| 3 |
|
---|
| 4 | interface
|
---|
| 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] | 42 | uses
|
---|
| 43 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
[541] | 44 | IniFiles, //kt for IniFile
|
---|
[453] | 45 | StdCtrls, ExtCtrls, ORCtrls, ORFn, ComCtrls, DKLang;
|
---|
| 46 |
|
---|
| 47 | type
|
---|
| 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 |
|
---|
| 83 | var
|
---|
| 84 | frmOptionsNotes: TfrmOptionsNotes;
|
---|
[541] | 85 | OptionsNotesIniFile : TIniFile; //kt 8/09
|
---|
| 86 | DefaultEditHTMLMode : boolean; //kt 8/09
|
---|
| 87 | FHTMLEditTextSize : integer; //kt 8/09
|
---|
[453] | 88 |
|
---|
| 89 | procedure DialogOptionsNotes(topvalue, leftvalue, fontsize: integer; var actiontype: Integer);
|
---|
[541] | 90 | procedure SetDefaultEditHTMLMode(Value : boolean); //kt 8/09
|
---|
| 91 | procedure Loaded; //kt 8/09
|
---|
[453] | 92 |
|
---|
| 93 | implementation
|
---|
| 94 |
|
---|
| 95 | {$R *.DFM}
|
---|
| 96 |
|
---|
| 97 | uses
|
---|
[541] | 98 | uCore, //kt 8/09
|
---|
| 99 | Registry, //kt 8/09
|
---|
[686] | 100 | rOptions, uOptions, rCore, rTIU, rDCSumm, uTemplates;
|
---|
[453] | 101 |
|
---|
[541] | 102 | const
|
---|
| 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 |
|
---|
| 106 | procedure SetRegHTMLViewSize(Size : integer); forward; //kt 8/09
|
---|
| 107 |
|
---|
[453] | 108 | procedure DialogOptionsNotes(topvalue, leftvalue, fontsize: integer; var actiontype: Integer);
|
---|
| 109 | // create the form and make it modal, return an action
|
---|
| 110 | var
|
---|
| 111 | frmOptionsNotes: TfrmOptionsNotes;
|
---|
| 112 | begin
|
---|
| 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;
|
---|
| 133 | end;
|
---|
| 134 |
|
---|
| 135 | procedure TfrmOptionsNotes.FormShow(Sender: TObject);
|
---|
| 136 | // displays defaults
|
---|
| 137 | // opening tab^use last tab^autosave seconds^verify note title
|
---|
| 138 | var
|
---|
| 139 | autosave, verify: integer;
|
---|
| 140 | cosigner: Int64;
|
---|
| 141 | values, cosignername: string;
|
---|
| 142 | begin
|
---|
| 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] | 161 | end;
|
---|
| 162 |
|
---|
| 163 | procedure TfrmOptionsNotes.btnOKClick(Sender: TObject);
|
---|
| 164 | // only saves values if they have been changed
|
---|
| 165 | // opening tab^use last tab^autosave seconds^verify note title
|
---|
| 166 | var
|
---|
| 167 | values: string;
|
---|
| 168 | begin
|
---|
| 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;
|
---|
| 190 | end;
|
---|
| 191 |
|
---|
| 192 | procedure TfrmOptionsNotes.txtAutoSaveChange(Sender: TObject);
|
---|
| 193 | var
|
---|
| 194 | maxvalue: integer;
|
---|
| 195 | begin
|
---|
| 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);
|
---|
| 209 | end;
|
---|
| 210 |
|
---|
| 211 | procedure TfrmOptionsNotes.txtAutoSaveKeyPress(Sender: TObject;
|
---|
| 212 | var Key: Char);
|
---|
| 213 | begin
|
---|
| 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;
|
---|
| 224 | end;
|
---|
| 225 |
|
---|
| 226 | procedure TfrmOptionsNotes.txtAutoSaveExit(Sender: TObject);
|
---|
| 227 | begin
|
---|
| 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;
|
---|
| 241 | end;
|
---|
| 242 |
|
---|
| 243 | procedure TfrmOptionsNotes.spnAutoSaveClick(Sender: TObject;
|
---|
| 244 | Button: TUDBtnType);
|
---|
| 245 | begin
|
---|
| 246 | txtAutoSave.SetFocus;
|
---|
| 247 | txtAutoSave.Tag := strtointdef(txtAutoSave.Text, 0);
|
---|
| 248 | end;
|
---|
| 249 |
|
---|
| 250 | procedure TfrmOptionsNotes.cboCosignerNeedData(Sender: TObject;
|
---|
| 251 | const StartFrom: String; Direction, InsertAt: Integer);
|
---|
| 252 | begin
|
---|
| 253 | cboCosigner.ForDataUse(rpcGetCosigners(StartFrom, Direction));
|
---|
| 254 | end;
|
---|
| 255 |
|
---|
| 256 | procedure TfrmOptionsNotes.cboCosignerExit(Sender: TObject);
|
---|
| 257 | begin
|
---|
| 258 | with cboCosigner do
|
---|
| 259 | if (Text = '') or (ItemIndex = -1) then
|
---|
| 260 | begin
|
---|
| 261 | ItemIndex := 0;
|
---|
| 262 | Text := DisplayText[0];
|
---|
| 263 | end;
|
---|
| 264 | end;
|
---|
| 265 |
|
---|
[541] | 266 |
|
---|
| 267 | procedure 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.
|
---|
| 272 | var
|
---|
| 273 | FontSizeData : array[0..3] of byte;
|
---|
| 274 | ZoomReg : TRegistry;
|
---|
| 275 | begin
|
---|
| 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;
|
---|
| 287 | end;
|
---|
| 288 |
|
---|
| 289 | procedure SetDefaultEditHTMLMode(Value : boolean);
|
---|
| 290 | //kt added entire function 8/09
|
---|
| 291 | begin
|
---|
| 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] | 305 | end;
|
---|
| 306 |
|
---|
| 307 | procedure TfrmOptionsNotes.cbDefaultHTMLModeClick(Sender: TObject);
|
---|
| 308 | //kt added entire function 8/09
|
---|
| 309 | begin
|
---|
| 310 | SetDefaultEditHTMLMode(cbDefaultHTMLMode.Checked);
|
---|
| 311 | end;
|
---|
| 312 |
|
---|
| 313 | procedure TfrmOptionsNotes.cboHTMLViewSizeChange(Sender: TObject);
|
---|
| 314 | //kt added entire function 8/09
|
---|
| 315 | begin
|
---|
| 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);
|
---|
| 320 | end;
|
---|
| 321 |
|
---|
| 322 | procedure Loaded;
|
---|
| 323 | //kt added entire function 8/09
|
---|
| 324 | begin
|
---|
| 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);
|
---|
| 331 | end;
|
---|
| 332 |
|
---|
| 333 | procedure TfrmOptionsNotes.FormCreate(Sender: TObject);
|
---|
| 334 | //kt added entire function 8/09
|
---|
| 335 | //NOTE: form is not created until first time needed.
|
---|
| 336 | begin
|
---|
| 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;
|
---|
| 343 | end;
|
---|
| 344 |
|
---|
| 345 | initialization
|
---|
| 346 |
|
---|
| 347 | finalization
|
---|
| 348 | OptionsNotesIniFile.Free; //kt 8/09
|
---|
| 349 |
|
---|
[453] | 350 | end.
|
---|