source: cprs/branches/HealthSevak-CPRS/CPRS-Chart/Templates/fTemplateFieldEditor.pas@ 1797

Last change on this file since 1797 was 1699, checked in by healthsevak, 10 years ago

Implemented the OpenSource based spell check feature

File size: 37.9 KB
Line 
1unit fTemplateFieldEditor;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 ORCtrls, StdCtrls, ExtCtrls, Menus, ComCtrls, uTemplateFields, ORFn,
8 ToolWin, MenuBar, ORClasses, ORDtTm, fBase508Form, VA508AccessibilityManager;
9
10type
11 TfrmTemplateFieldEditor = class(TfrmBase508Form)
12 pnlBottom: TPanel;
13 btnOK: TButton;
14 btnCancel: TButton;
15 pnlObjs: TPanel;
16 cbxObjs: TORComboBox;
17 lblObjs: TLabel;
18 splLeft: TSplitter;
19 pnlRight: TPanel;
20 pnlPreview: TPanel;
21 lblNotes: TLabel;
22 pnlObjInfo: TPanel;
23 lblName: TLabel;
24 lblS2: TLabel;
25 lblLM: TLabel;
26 edtName: TCaptionEdit;
27 splBottom: TSplitter;
28 lblS1: TLabel;
29 edtLMText: TCaptionEdit;
30 cbxType: TORComboBox;
31 lblType: TLabel;
32 reNotes: TRichEdit;
33 btnApply: TButton;
34 btnPreview: TButton;
35 mnuMain: TMainMenu;
36 mnuAction: TMenuItem;
37 mnuNew: TMenuItem;
38 mnuCopy: TMenuItem;
39 cbHide: TCheckBox;
40 pnlTop: TPanel;
41 MenuBar1: TMenuBar;
42 btnNew: TButton;
43 btnCopy: TButton;
44 mnuDelete: TMenuItem;
45 btnDelete: TButton;
46 mnuPreview: TMenuItem;
47 popText: TPopupMenu;
48 mnuBPUndo: TMenuItem;
49 N8: TMenuItem;
50 mnuBPCut: TMenuItem;
51 mnuBPCopy: TMenuItem;
52 mnuBPPaste: TMenuItem;
53 mnuBPSelectAll: TMenuItem;
54 N2: TMenuItem;
55 mnuBPCheckGrammar: TMenuItem;
56 mnuBPSpellCheck: TMenuItem;
57 lblTextLen: TLabel;
58 edtTextLen: TCaptionEdit;
59 udTextLen: TUpDown;
60 pnlSwap: TPanel;
61 edtDefault: TCaptionEdit;
62 pnlNum: TPanel;
63 edtURL: TCaptionEdit;
64 udDefNum: TUpDown;
65 edtDefNum: TCaptionEdit;
66 udMinVal: TUpDown;
67 edtMinVal: TCaptionEdit;
68 lblMin: TLabel;
69 udInc: TUpDown;
70 edtInc: TCaptionEdit;
71 lblInc: TLabel;
72 lblMaxVal: TLabel;
73 edtMaxVal: TCaptionEdit;
74 udMaxVal: TUpDown;
75 reItems: TRichEdit;
76 lblLength: TLabel;
77 edtLen: TCaptionEdit;
78 udLen: TUpDown;
79 cbxDefault: TORComboBox;
80 lblS3: TLabel;
81 gbIndent: TGroupBox;
82 lblIndent: TLabel;
83 edtIndent: TCaptionEdit;
84 udIndent: TUpDown;
85 udPad: TUpDown;
86 edtPad: TCaptionEdit;
87 lblPad: TLabel;
88 gbMisc: TGroupBox;
89 cbActive: TCheckBox;
90 cbRequired: TCheckBox;
91 cbSepLines: TCheckBox;
92 pnlDate: TPanel;
93 edtDateDef: TCaptionEdit;
94 cbxDateType: TORComboBox;
95 lblDateType: TLabel;
96 cbExclude: TCheckBox;
97 lblReq: TStaticText;
98 lblLine: TLabel;
99 lblCol: TLabel;
100 N14: TMenuItem;
101 mnuInsertTemplateField: TMenuItem;
102 popNoteMemoSpellOpenSource: TMenuItem; //WordVisTA@SK_Arora@HealthSevak to implement OpenSource SpellCheck Engine
103 procedure cbxObjsNeedData(Sender: TObject; const StartFrom: String;
104 Direction, InsertAt: Integer);
105 procedure FormCreate(Sender: TObject);
106 procedure cbxObjsChange(Sender: TObject);
107 procedure edtNameChange(Sender: TObject);
108 procedure cbxTypeChange(Sender: TObject);
109 procedure edtLenChange(Sender: TObject);
110 procedure edtDefaultChange(Sender: TObject);
111 procedure cbxDefaultChange(Sender: TObject);
112 procedure edtLMTextChange(Sender: TObject);
113 procedure cbActiveClick(Sender: TObject);
114 procedure mnuNewClick(Sender: TObject);
115 procedure btnOKClick(Sender: TObject);
116 procedure btnApplyClick(Sender: TObject);
117 procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
118 procedure btnCancelClick(Sender: TObject);
119 procedure reItemsChange(Sender: TObject);
120 procedure cbHideClick(Sender: TObject);
121 procedure edtNameExit(Sender: TObject);
122 procedure mnuCopyClick(Sender: TObject);
123 procedure mnuDeleteClick(Sender: TObject);
124 procedure btnPreviewClick(Sender: TObject);
125 procedure mnuActionClick(Sender: TObject);
126 procedure cbRequiredClick(Sender: TObject);
127 procedure pnlObjsResize(Sender: TObject);
128 procedure FormDestroy(Sender: TObject);
129 procedure cbxObjsSynonymCheck(Sender: TObject; const Text: String;
130 var IsSynonym: Boolean);
131 procedure popTextPopup(Sender: TObject);
132 procedure mnuBPUndoClick(Sender: TObject);
133 procedure mnuBPCutClick(Sender: TObject);
134 procedure mnuBPCopyClick(Sender: TObject);
135 procedure mnuBPPasteClick(Sender: TObject);
136 procedure mnuBPSelectAllClick(Sender: TObject);
137 procedure mnuBPCheckGrammarClick(Sender: TObject);
138 procedure mnuBPSpellCheckClick(Sender: TObject);
139 procedure cbSepLinesClick(Sender: TObject);
140 procedure edtpopControlEnter(Sender: TObject);
141 procedure cbxObjsKeyDown(Sender: TObject; var Key: Word;
142 Shift: TShiftState);
143 procedure edtTextLenChange(Sender: TObject);
144 procedure edtDefNumChange(Sender: TObject);
145 procedure edtMinValChange(Sender: TObject);
146 procedure edtMaxValChange(Sender: TObject);
147 procedure edtIncChange(Sender: TObject);
148 procedure edtURLChange(Sender: TObject);
149 procedure edtPadChange(Sender: TObject);
150 procedure edtIndentChange(Sender: TObject);
151 procedure reNotesChange(Sender: TObject);
152 procedure cbxDateTypeChange(Sender: TObject);
153 procedure cbExcludeClick(Sender: TObject);
154 procedure FormResize(Sender: TObject);
155 procedure reItemsResizeRequest(Sender: TObject; Rect: TRect);
156 procedure reItemsSelectionChange(Sender: TObject);
157 procedure mnuInsertTemplateFieldClick(Sender: TObject);
158 procedure ControlExit(Sender: TObject);
159 procedure reNotesKeyUp(Sender: TObject; var Key: Word;
160 Shift: TShiftState);
161 private
162 CopyFld, FFld: TTemplateField;
163 FUpdating: boolean;
164 FReloadChanges: boolean;
165 FChangesPending: boolean;
166 FDeleted: TORStringList;
167 FHideSynonyms: boolean;
168 FLastRect: TRect;
169 procedure UpdateControls;
170 procedure SyncItems(DoUpdate: boolean = TRUE);
171 function SaveChanges: boolean;
172 procedure ResetListEntry;
173 procedure VerifyName;
174 procedure EnableButtons;
175 procedure SetFld(const Value: TTemplateField);
176 procedure SetHideSynonyms(const Value: boolean);
177 function GetPopupControl: TCustomEdit;
178 public
179 { Public declarations }
180 end;
181
182function EditDialogFields: boolean;
183
184implementation
185
186uses rTemplates, fTemplateDialog, Clipbrd, uSpell, uConst,
187 fTemplateFields, VAUtils;
188
189{$R *.DFM}
190
191{ TfrmDlgObjEditor }
192
193var
194 frmTemplateFields: TfrmTemplateFields = nil;
195
196
197function EditDialogFields: boolean;
198var
199 frmTemplateFieldEditor: TfrmTemplateFieldEditor;
200
201begin
202 frmTemplateFieldEditor := TfrmTemplateFieldEditor.Create(Application);
203 try
204 frmTemplateFieldEditor.ShowModal;
205 Result := frmTemplateFieldEditor.FReloadChanges;
206 finally
207 frmTemplateFieldEditor.Free;
208 end;
209end;
210
211procedure TfrmTemplateFieldEditor.UpdateControls;
212const
213 DefTxt = 'Default:';
214
215var
216 ok, edt, txt, tmp: boolean;
217 Y, idx, Max: integer;
218 wpTxt: string;
219
220 procedure SetLbl(const Text: string);
221 var
222 lbl: TLabel;
223
224 begin
225 inc(idx);
226 case idx of
227 1: lbl := lblS1;
228 2: lbl := lblS2;
229 3: lbl := lblS3;
230 else
231 lbl := nil;
232 end;
233 if assigned(lbl) then
234 lbl.Caption := Text;
235 end;
236
237 procedure SetY(Control: TControl; const Text: string);
238 begin
239 if (Control.Visible) then
240 begin
241 Control.Top := Y;
242 inc(Y, Control.Height);
243 SetLbl(Text);
244 end;
245 end;
246
247begin
248 if(not FUpdating) then
249 begin
250 FUpdating := TRUE;
251 try
252 Y := 0;
253 idx := 0;
254 ok := assigned(FFld);
255 if(ok) then
256 begin
257 edt := (FFld.FldType in EditLenTypes);
258 txt := (FFld.FldType in EditDfltTypes);
259 end
260 else
261 begin
262 edt := FALSE;
263 txt := FALSE;
264 end;
265 lblName.Enabled := ok;
266 edtName.Enabled := ok;
267 lblType.Enabled := ok;
268 cbxType.Enabled := ok;
269 lblLM.Enabled := ok;
270 edtLMText.Enabled := ok;
271 cbActive.Enabled := ok;
272
273 gbMisc.Enabled := ok;
274 lblNotes.Enabled := ok;
275 reNotes.Enabled := ok;
276 if(ok) then
277 begin
278 edtName.Text := FFld.FldName;
279 cbxType.ItemIndex := ord(FFld.FldType);
280 edtLMText.Text := FFld.LMText;
281 cbActive.Checked := FFld.Inactive;
282 reNotes.Lines.Text := FFld.Notes;
283 end
284 else
285 begin
286 edtName.Text := '';
287 cbxType.ItemIndex := -1;
288 edtLMText.Text := '';
289 cbActive.Checked := FALSE;
290 reNotes.Clear;
291 end;
292
293 tmp := ok and (not (FFld.FldType in NoRequired));
294 cbRequired.Enabled := tmp;
295 if tmp then
296 cbRequired.Checked := FFld.Required
297 else
298 cbRequired.Checked := FALSE;
299
300 pnlSwap.DisableAlign;
301 try
302 tmp := ok and (FFld.FldType in SepLinesTypes);
303 cbSepLines.Enabled := tmp;
304 if tmp then
305 cbSepLines.Checked := FFld.SepLines
306 else
307 cbSepLines.Checked := FALSE;
308
309 tmp := ok and (FFld.FldType in ExcludeText);
310 cbExclude.Enabled := tmp;
311 if tmp then
312 cbExclude.Checked := FFld.SepLines
313 else
314 cbExclude.Checked := FALSE;
315
316 lblLength.Enabled := edt;
317 if ok and (FFld.FldType = dftWP) then
318 begin
319 lblTextLen.Caption := 'Num Lines:';
320 udLen.Min := 5;
321 udLen.Max := 74;
322 udTextLen.Min := 2;
323 udTextLen.Max := MaxTFWPLines;
324 end
325 else
326 begin
327 udLen.Min := 1;
328 udLen.Max := 70;
329 udTextLen.Min := 0;
330 udTextLen.Max := 240;
331 lblTextLen.Caption := 'Text Len:';
332 end;
333
334 lblTextLen.Enabled := edt;
335 edtTextLen.Enabled := edt;
336 udTextLen.Enabled := edt;
337 edtLen.Enabled := edt;
338 udLen.Enabled := edt;
339
340 edtDefault.Visible := txt;
341 SetY(edtDefault, DefTxt);
342 Max := MaxTFEdtLen;
343
344 if(edt) then
345 begin
346 udLen.Associate := edtLen;
347 udLen.Position := FFld.MaxLen;
348 udTextLen.Associate := edtTextLen;
349 udTextLen.Position := FFld.TextLen;
350 if txt then
351 Max := FFld.MaxLen;
352 end
353 else
354 begin
355 udLen.Associate := nil;
356 edtLen.Text := '';
357 udTextLen.Associate := nil;
358 edtTextLen.Text := '';
359 end;
360
361 if txt then
362 begin
363 edtDefault.MaxLength := Max;
364 edtDefault.Text := copy(FFld.EditDefault, 1, Max);
365 end;
366
367 gbIndent.Enabled := ok;
368 lblIndent.Enabled := ok;
369 edtIndent.Enabled := ok;
370 udIndent.Enabled := ok;
371 if ok then
372 begin
373 udIndent.Associate := edtIndent;
374 udIndent.Position := FFld.Indent;
375 end
376 else
377 begin
378 udIndent.Associate := nil;
379 edtIndent.Text := '';
380 end;
381
382 tmp := ok and (not cbExclude.Checked);
383 lblPad.Enabled := tmp;
384 edtPad.Enabled := tmp;
385 udPad.Enabled := tmp;
386 if tmp then
387 begin
388 udPad.Associate := edtPad;
389 udPad.Position := FFld.Pad;
390 end
391 else
392 begin
393 udPad.Associate := nil;
394 edtPad.Text := '';
395 end;
396
397 tmp := ok and (FFld.FldType = dftNumber);
398 pnlNum.Visible := tmp;
399 SetY(pnlNum, DefTxt);
400 if tmp then
401 begin
402 udDefNum.Position := StrToIntDef(FFld.EditDefault, 0);
403 udMinVal.Position := FFld.MinVal;
404 udMaxVal.Position := FFld.MaxVal;
405 udInc.Position := FFld.Increment;
406 end;
407
408 tmp := ok and (FFld.FldType = dftDate);
409 pnlDate.Visible := tmp;
410 SetY(pnlDate, DefTxt);
411 if tmp then
412 begin
413 edtDateDef.Text := FFld.EditDefault;
414 cbxDateType.SelectByID(TemplateFieldDateCodes[FFld.DateType]);
415 end;
416
417 tmp := ok and (FFld.FldType in ItemDfltTypes);
418 cbxDefault.Visible := tmp;
419 SetY(cbxDefault, DefTxt);
420
421 tmp := ok and (FFld.FldType = dftHyperlink);
422 edtURL.Visible := tmp;
423 SetY(edtURL, 'Address:');
424 if tmp then
425 edtURL.Text := FFld.URL;
426
427 tmp := ok and (FFld.FldType in FldItemTypes);
428 reItems.Visible := tmp;
429 lblLine.Visible := tmp;
430 lblCol.Visible := tmp;
431 if tmp then
432 begin
433 if FFld.FldType = dftWP then
434 wpTxt := DefTxt
435 else
436 wpTxt := 'Items:';
437 end
438 else
439 wpTxt := '';
440 SetY(reItems, wpTxt);
441 if tmp then
442 reItems.Lines.Text := FFld.Items
443 else
444 reItems.Clear;
445 finally
446 pnlSwap.EnableAlign;
447 end;
448
449 SetLbl('');
450 SetLbl('');
451 SetLbl('');
452 SyncItems(FALSE);
453 FormResize(Self);
454 finally
455 FUpdating := FALSE;
456 end;
457 end;
458end;
459
460procedure TfrmTemplateFieldEditor.SyncItems(DoUpdate: boolean = TRUE);
461var
462 i, idx, Siz, Max1, Max2: integer;
463 ChangeSizes: boolean;
464
465begin
466 if DoUpdate and FUpdating then
467 exit;
468 Max1 := 0;
469 Max2 := 0;
470 ChangeSizes := FALSE;
471 FUpdating := TRUE;
472 try
473 QuickCopy(reItems, cbxDefault);
474 idx := -1;
475 if(assigned(FFld)) and reItems.Visible and cbxDefault.Visible then
476 begin
477 ChangeSizes := TRUE;
478 for i := 0 to reItems.Lines.Count-1 do
479 begin
480 Siz := length(StripEmbedded(reItems.Lines[i]));
481 if Max1 < Siz then
482 Max1 := Siz;
483 if(idx < 0) and (FFld.ItemDefault = reItems.Lines[i]) then
484 idx := i;
485 end;
486 Max2 := Max1;
487 if Max1 > MaxTFEdtLen then
488 Max1 := MaxTFEdtLen;
489 end;
490 cbxDefault.ItemIndex := idx;
491 finally
492 FUpdating := FALSE;
493 end;
494 if ChangeSizes and DoUpdate then
495 begin
496 udLen.Position := Max1;
497 if (not udTextLen.Enabled) or
498 ((udTextLen.Position > 0) and (udTextLen.Position < Max2)) then
499 udTextLen.Position := Max2;
500 end;
501end;
502
503procedure TfrmTemplateFieldEditor.cbxObjsNeedData(Sender: TObject;
504 const StartFrom: String; Direction, InsertAt: Integer);
505var
506 tmp: TORStringList;
507 i, idx: integer;
508
509begin
510 tmp := TORStringList.Create;
511 try
512 FastAssign(SubSetOfTemplateFields(StartFrom, Direction), tmp);
513 for i := 0 to FDeleted.Count-1 do
514 begin
515 idx := tmp.IndexOfPiece(Piece(FDeleted[i],U,1), U, 1);
516 if(idx >= 0) then
517 tmp.delete(idx);
518 end;
519 ConvertCodes2Text(tmp, FALSE);
520 cbxObjs.ForDataUse(tmp);
521 finally
522 tmp.Free;
523 end;
524end;
525
526procedure TfrmTemplateFieldEditor.FormCreate(Sender: TObject);
527var
528 i: integer;
529 Child: TControl;
530 Overage: integer;
531begin
532 FDeleted := TORStringList.Create;
533 FHideSynonyms := TRUE;
534 cbxObjs.InitLongList('');
535 cbxObjs.ItemHeight := 15;
536 UpdateControls;
537 ResizeAnchoredFormToFont(self);
538 //ResizeAnchoredFormToFont does the pnlObjInfo panel wrong. So we fix it here.
539 gbMisc.Top := pnlObjInfo.ClientHeight - gbMisc.Height - 5;
540 gbIndent.Top := gbMisc.Top;
541 edtLMText.Top := gbMisc.Top - edtLMText.Height - 2;
542 lblLM.Top := edtLMText.Top + 5;
543 pnlSwap.Height := lblLM.Top - pnlSwap.Top;
544 Overage := edtName.Left + edtName.Width - pnlObjInfo.ClientWidth - 4;
545 for i := 0 to pnlObjInfo.ControlCount-1 do begin
546 Child := pnlObjInfo.Controls[i];
547 if (akRight in Child.Anchors) then begin
548 if (akLeft in Child.Anchors) then
549 Child.Width := Child.Width - Overage
550 else
551 Child.Left := Child.Left - Overage;
552 end;
553 end;
554end;
555
556procedure TfrmTemplateFieldEditor.cbxObjsChange(Sender: TObject);
557begin
558 if(cbxObjs.ItemIEN <> 0) then
559 SetFld(GetTemplateField(cbxObjs.ItemID, TRUE))
560 else
561 SetFld(nil);
562 UpdateControls;
563end;
564
565procedure TfrmTemplateFieldEditor.edtNameChange(Sender: TObject);
566var
567 ok: boolean;
568
569begin
570 if(not FUpdating) and (assigned(FFld)) then
571 begin
572 if (not FFld.NameChanged) and (not FFld.NewField) then
573 begin
574 ok := InfoBox('*** WARNING ***' + CRLF + CRLF +
575 'This template field has been saved, and may have been used in one or more' + CRLF +
576 'boilerplates. Boilerplates can be found in templates, titles, reasons for request' + CRLF +
577 'and reminder dialogs. Renaming this template field will cause any boilerplates' + CRLF +
578 'that use it to no longer function correctly.' + CRLF + CRLF +
579 'Are you sure you want to rename the ' + FFld.FldName + ' template field?',
580 'Warning', MB_YESNO or MB_ICONWARNING) = IDYES;
581 if ok then
582 InfoBox('Template field will be renamed when OK or Apply is pressed.', 'Information', MB_OK or MB_ICONINFORMATION)
583 else
584 begin
585 FUpdating := TRUE;
586 try
587 edtName.Text := FFld.FldName;
588 finally
589 FUpdating := FALSE;
590 end;
591 end;
592 end
593 else
594 ok := TRUE;
595 if ok then
596 begin
597 FFld.FldName := edtName.Text;
598 edtName.Text := FFld.FldName;
599 FChangesPending := TRUE;
600 ResetListEntry;
601 end;
602 end;
603end;
604
605procedure TfrmTemplateFieldEditor.cbxTypeChange(Sender: TObject);
606begin
607 if(not FUpdating) and (assigned(FFld)) then
608 begin
609 if(cbxType.ItemIndex < 0) then
610 begin
611 FUpdating := TRUE;
612 try
613 cbxType.ItemIndex := 0;
614 finally
615 FUpdating := FALSE;
616 end;
617 end;
618 FFld.FldType := TTemplateFieldType(cbxType.ItemIndex);
619 end;
620 EnableButtons;
621 UpdateControls;
622end;
623
624procedure TfrmTemplateFieldEditor.edtLenChange(Sender: TObject);
625var
626 v: integer;
627 ok: boolean;
628
629begin
630 EnsureText(edtLen, udLen);
631 if((not FUpdating) and (assigned(FFld)) and (FFld.FldType in (EditLenTypes))) then
632 begin
633 EnsureText(edtLen, udLen);
634 FFld.MaxLen := udLen.Position;
635 udLen.Position := FFld.MaxLen;
636 if edtDefault.Visible then
637 begin
638 edtDefault.MaxLength := FFld.MaxLen;
639 edtDefault.Text := copy(edtDefault.Text,1,FFld.MaxLen);
640 end;
641 case FFLd.FldType of
642 dftEditBox: ok := TRUE;
643 dftComboBox: ok := (udTextLen.Position > 0);
644 else ok := FALSE;
645 end;
646 if ok then
647 begin
648 v := udLen.Position;
649 if udTextLen.Position < v then
650 udTextLen.Position := v;
651 end;
652 end;
653end;
654
655procedure TfrmTemplateFieldEditor.edtDefaultChange(Sender: TObject);
656begin
657 if((not FUpdating) and (assigned(FFld)) and (FFld.FldType in EditDfltType2)) then
658 begin
659 FFld.EditDefault := TEdit(Sender).Text;
660 TEdit(Sender).Text := FFld.EditDefault;
661 end;
662end;
663
664procedure TfrmTemplateFieldEditor.cbxDefaultChange(Sender: TObject);
665begin
666 if((not FUpdating) and (assigned(FFld)) and (FFld.FldType in ItemDfltTypes)) then
667 begin
668 FFld.ItemDefault := cbxDefault.Text;
669 SyncItems;
670 end;
671end;
672
673procedure TfrmTemplateFieldEditor.edtLMTextChange(Sender: TObject);
674begin
675 if((not FUpdating) and (assigned(FFld))) then
676 begin
677 FFld.LMText := edtLMText.Text;
678 edtLMText.Text := FFld.LMText;
679 end;
680end;
681
682procedure TfrmTemplateFieldEditor.cbActiveClick(Sender: TObject);
683begin
684 if((not FUpdating) and (assigned(FFld))) then
685 begin
686 FFld.Inactive := cbActive.Checked;
687 cbActive.Checked := FFld.Inactive;
688 FChangesPending := TRUE;
689 //ResetListEntry;
690 end;
691end;
692
693procedure TfrmTemplateFieldEditor.mnuNewClick(Sender: TObject);
694begin
695 SetFld(TTemplateField.Create(nil));
696 if(assigned(FFld)) then
697 begin
698 FChangesPending := TRUE;
699 if cbxObjs.ShortCount = 0 then
700 begin
701 cbxObjs.Items.Insert(0,LLS_LINE);
702 cbxObjs.Items.Insert(1,'');
703 end;
704 if(assigned(CopyFld)) then
705 FFld.Assign(CopyFld);
706 cbxObjs.Items.Insert(0,FFld.ID + U + FFld.FldName);
707 cbxObjs.SelectByID(FFld.ID);
708 cbxObjsChange(nil);
709 if(assigned(FFld)) then
710 edtName.SetFocus;
711 end
712 else
713 UpdateControls;
714end;
715
716procedure TfrmTemplateFieldEditor.btnOKClick(Sender: TObject);
717begin
718 SaveChanges;
719end;
720
721procedure TfrmTemplateFieldEditor.btnApplyClick(Sender: TObject);
722var
723 tmp: string;
724begin
725 SaveChanges;
726 cbxObjs.Clear;
727 if assigned(FFld) then
728 tmp := FFld.FldName
729 else
730 tmp := '';
731 cbxObjs.InitLongList(tmp);
732 cbxObjs.ItemIndex := 0;
733 cbxObjsChange(cbxObjs);
734end;
735
736procedure TfrmTemplateFieldEditor.FormCloseQuery(Sender: TObject;
737 var CanClose: Boolean);
738var
739 ans: word;
740
741begin
742 if(AnyTemplateFieldsModified) then
743 begin
744 ans := InfoBox('Save Changes?', 'Confirmation', MB_YESNOCANCEL or MB_ICONQUESTION);
745 if(ans = IDCANCEL) then
746 CanClose := FALSE
747 else
748 if(ans = IDYES) then
749 CanClose := SaveChanges;
750 end;
751end;
752
753procedure TfrmTemplateFieldEditor.btnCancelClick(Sender: TObject);
754var
755 i: integer;
756
757begin
758 for i := 0 to FDeleted.Count-1 do
759 UnlockTemplateField(Piece(FDeleted[i],U,1));
760 FDeleted.Clear;
761 ClearModifiedTemplateFields;
762end;
763
764function TfrmTemplateFieldEditor.SaveChanges: boolean;
765var
766 ans: word;
767 Errors: string;
768 i: integer;
769
770begin
771 for i := 0 to FDeleted.Count-1 do
772 DeleteTemplateField(Piece(FDeleted[i],U,1));
773 FDeleted.Clear;
774 Result := TRUE;
775 Errors := SaveTemplateFieldErrors;
776 if(Errors <> '') then
777 begin
778 ans := InfoBox(Errors + CRLF + CRLF + 'Cancel changes to these Template Fields?',
779 'Confirmation', MB_YESNO or MB_ICONQUESTION);
780 if(ans = IDYES) then
781 ClearModifiedTemplateFields
782 else
783 Result := FALSE;
784 end;
785 if(FChangesPending) then
786 FReloadChanges := TRUE;
787end;
788
789procedure TfrmTemplateFieldEditor.reItemsChange(Sender: TObject);
790begin
791 if((not FUpdating) and (assigned(FFld)) and (FFld.FldType in FldItemTypes)) then
792 begin
793 FFld.Items := reItems.Lines.Text;
794 SyncItems;
795 end;
796end;
797
798procedure TfrmTemplateFieldEditor.cbHideClick(Sender: TObject);
799begin
800 SetHideSynonyms(cbHide.Checked);
801end;
802
803procedure TfrmTemplateFieldEditor.edtNameExit(Sender: TObject);
804begin
805 if (ActiveControl <> btnCancel) and (ActiveControl <> btnDelete) then
806 VerifyName;
807end;
808
809procedure TfrmTemplateFieldEditor.VerifyName;
810var
811 bad: boolean;
812
813begin
814 if assigned(FFld) then
815 begin
816 if FDeleted.IndexOfPiece(FFld.FldName, U, 2) >= 0 then
817 begin
818 ShowMsg('Template field can not be named the same as a deleted' + CRLF +
819 'field until OK or Apply has been pressed.');
820 bad := TRUE;
821 end
822 else
823 bad := TemplateFieldNameProblem(FFld);
824 if bad then
825 edtName.SetFocus;
826 end;
827end;
828
829procedure TfrmTemplateFieldEditor.mnuCopyClick(Sender: TObject);
830begin
831 if assigned(FFld) then
832 begin
833 CopyFld := FFld;
834 try
835 mnuNewClick(nil);
836 finally
837 CopyFld := nil;
838 end;
839 end;
840end;
841
842procedure TfrmTemplateFieldEditor.SetFld(const Value: TTemplateField);
843begin
844 FFld := Value;
845 EnableButtons;
846end;
847
848procedure TfrmTemplateFieldEditor.mnuDeleteClick(Sender: TObject);
849var
850 idx: integer;
851 ok: boolean;
852 Answer: word;
853 txt: string;
854 btns: TMsgDlgButtons;
855
856begin
857 if assigned(FFld) then
858 begin
859 ok := (FFld.NewField);
860 if not ok then
861 begin
862 btns := [mbYes, mbNo];
863 if FFld.Inactive then
864 txt := ''
865 else
866 begin
867 txt := ' Rather than deleting, you may want' + CRLF +
868 'to inactivate this template field instead. You may inactivate this template by' + CRLF +
869 'pressing the Ignore button now.';
870 include(btns, mbIgnore);
871 end;
872 Answer := MessageDlg('*** WARNING ***' + CRLF + CRLF +
873 'This template field has been saved, and may have been used in one or more' + CRLF +
874 'boilerplates. Boilerplates can be found in templates, titles, reasons for request' + CRLF +
875 'and reminder dialogs. Deleting this template field will cause any boilerplates' + CRLF +
876 'that use it to no longer function correctly.' + txt + CRLF + CRLF +
877 'Are you sure you want to delete the ' + FFld.FldName + ' template field?',
878 mtWarning, btns, 0);
879 ok := (Answer = mrYes);
880 if(Answer = mrIgnore) then
881 cbActive.Checked := TRUE;
882 end;
883 if ok then
884 begin
885 if(FFld.NewField or FFld.CanModify) then
886 begin
887 if FFld.NewField then
888 begin
889 idx := cbxObjs.ItemIndex;
890 cbxObjs.ItemIndex := -1;
891 cbxObjs.Items.Delete(idx);
892 if cbxObjs.Items[0] = LLS_LINE then
893 begin
894 cbxObjs.Items.Delete(1);
895 cbxObjs.Items.Delete(0);
896 end;
897 end
898 else
899 begin
900 FDeleted.Add(FFld.ID + U + FFld.FldName);
901 cbxObjs.ItemIndex := -1;
902 end;
903 end;
904 FFld.Free;
905 SetFld(nil);
906 UpdateControls;
907 cbxObjs.InitLongList('');
908 FChangesPending := TRUE;
909 end;
910 end;
911end;
912
913procedure TfrmTemplateFieldEditor.ResetListEntry;
914var
915 txt: string;
916
917begin
918 if(assigned(FFld) and FFld.NewField and (cbxObjs.ItemIndex >= 0)) then
919 begin
920 txt := FFld.ID + U + FFld.FldName;
921 //if(FFld.Inactive) then
922 //txt := txt + ' <Inactive>';
923 cbxObjs.Items[cbxObjs.ItemIndex] := txt;
924 cbxObjs.ItemIndex := cbxObjs.ItemIndex;
925 end;
926end;
927
928procedure TfrmTemplateFieldEditor.btnPreviewClick(Sender: TObject);
929var
930 TmpSL: TStringList;
931
932begin
933 if(assigned(FFld)) then
934 begin
935 TmpSL := TStringList.Create;
936 try
937 TmpSL.Add(TemplateFieldBeginSignature + FFld.FldName + TemplateFieldEndSignature);
938 CheckBoilerplate4Fields(TmpSL, 'Preview Template Field: ' + FFld.FldName, TRUE);
939 finally
940 TmpSL.Free;
941 end;
942 end;
943end;
944
945procedure TfrmTemplateFieldEditor.EnableButtons;
946begin
947 btnCopy.Enabled := assigned(FFld);
948 mnuCopy.Enabled := btnCopy.Enabled;
949 btnDelete.Enabled := btnCopy.Enabled; // (assigned(FFld) and FFld.NewField);
950 mnuDelete.Enabled := btnDelete.Enabled;
951 btnPreview.Enabled := assigned(FFld) and (FFld.FldType <> dftUnknown);
952 mnuPreview.Enabled := btnPreview.Enabled;
953end;
954
955procedure TfrmTemplateFieldEditor.mnuActionClick(Sender: TObject);
956begin
957 EnableButtons;
958end;
959
960procedure TfrmTemplateFieldEditor.cbRequiredClick(Sender: TObject);
961begin
962 if((not FUpdating) and (assigned(FFld))) then
963 begin
964 FFld.Required := cbRequired.Checked;
965 cbRequired.Checked := FFld.Required;
966 end;
967end;
968
969procedure TfrmTemplateFieldEditor.pnlObjsResize(Sender: TObject);
970begin
971 btnPreview.Left := pnlRight.Left;
972end;
973
974procedure TfrmTemplateFieldEditor.FormDestroy(Sender: TObject);
975begin
976 FDeleted.Free;
977 if(assigned(frmTemplateFields)) then begin
978 frmTemplateFields.FRee;
979 frmTemplateFields := nil;
980 end; {if}
981
982end;
983
984procedure TfrmTemplateFieldEditor.SetHideSynonyms(const Value: boolean);
985begin
986 FHideSynonyms := Value;
987 cbxObjs.HideSynonyms := FALSE; // Refresh Display
988 cbxObjs.HideSynonyms := TRUE;
989end;
990
991procedure TfrmTemplateFieldEditor.cbxObjsSynonymCheck(Sender: TObject;
992 const Text: String; var IsSynonym: Boolean);
993begin
994 if not FHideSynonyms then
995 IsSynonym := FALSE;
996 if(FDeleted.Count > 0) and (FDeleted.IndexOfPiece(Text,U,2) >= 0) then
997 IsSynonym := TRUE;
998end;
999
1000procedure TfrmTemplateFieldEditor.popTextPopup(Sender: TObject);
1001var
1002 HasText, CanEdit, isre: boolean;
1003 ce: TCustomEdit;
1004 ShowTempField: boolean;
1005
1006begin
1007 ce := GetPopupControl;
1008 if assigned(ce) then
1009 begin
1010 isre := (ce is TRichEdit);
1011 CanEdit := (not TORExposedCustomEdit(ce).ReadOnly);
1012 mnuBPUndo.Enabled := (CanEdit and (ce.Perform(EM_CANUNDO, 0, 0) <> 0));
1013 if isre then
1014 HasText := (TRichEdit(ce).Lines.Count > 0)
1015 else
1016 HasText := (Text <> '');
1017 mnuBPSelectAll.Enabled := HasText;
1018 mnuBPCopy.Enabled := HasText and (ce.SelLength > 0);
1019 mnuBPPaste.Enabled := (CanEdit and Clipboard.HasFormat(CF_TEXT));
1020 mnuBPCut.Enabled := (CanEdit and HasText and (ce.SelLength > 0));
1021 ShowTempField := FALSE;
1022 if CanEdit then
1023 if (not assigned(frmTemplateFields)) or
1024 (assigned(frmTemplateFields) and not frmTemplateFields.Visible) then
1025 if (ce = reItems) or
1026 (ce = edtDefault) then
1027 ShowTempField := TRUE;
1028 mnuInsertTemplateField.Enabled := ShowTempField;
1029 end
1030 else
1031 begin
1032 isre := FALSE;
1033 HasText := FALSE;
1034 CanEdit := FALSE;
1035 mnuBPPaste.Enabled := FALSE;
1036 mnuBPCopy.Enabled := FALSE;
1037 mnuBPCut.Enabled := FALSE;
1038 mnuBPSelectAll.Enabled := FALSE;
1039 mnuBPUndo.Enabled := FALSE;
1040 mnuInsertTemplateField.Enabled := FALSE;
1041 end;
1042
1043 mnuBPSpellCheck.Visible := isre;
1044 popNoteMemoSpellOpenSource.Visible := isre; //WordVisTA@SK_Arora@HealthSevak to implement OpenSource SpellCheck Engine
1045 mnuBPCheckGrammar.Visible := isre;
1046
1047 if isre and HasText and CanEdit then
1048 begin
1049 mnuBPSpellCheck.Enabled := SpellCheckAvailable;
1050 popNoteMemoSpellOpenSource.Enabled := SpellCheckAvailable; //WordVisTA@SK_Arora@HealthSevak to implement OpenSource SpellCheck Engine
1051 mnuBPCheckGrammar.Enabled := SpellCheckAvailable;
1052 end
1053 else
1054 begin
1055 mnuBPSpellCheck.Enabled := FALSE;
1056 popNoteMemoSpellOpenSource.Enabled := False; //WordVisTA@SK_Arora@HealthSevak to implement OpenSource SpellCheck Engine
1057 mnuBPCheckGrammar.Enabled := FALSE;
1058 end;
1059end;
1060
1061function TfrmTemplateFieldEditor.GetPopupControl: TCustomEdit;
1062begin
1063 if assigned(popText.PopupComponent) and (popText.PopupComponent is TCustomEdit) then
1064 Result := TCustomEdit(popText.PopupComponent)
1065 else
1066 Result := nil;
1067end;
1068
1069procedure TfrmTemplateFieldEditor.mnuBPUndoClick(Sender: TObject);
1070var
1071 ce: TCustomEdit;
1072
1073begin
1074 ce := GetPopupControl;
1075 if assigned(ce) then
1076 ce.Perform(EM_UNDO, 0, 0);
1077end;
1078
1079procedure TfrmTemplateFieldEditor.mnuBPCutClick(Sender: TObject);
1080var
1081 ce: TCustomEdit;
1082
1083begin
1084 ce := GetPopupControl;
1085 if assigned(ce) then
1086 ce.CutToClipboard;
1087end;
1088
1089procedure TfrmTemplateFieldEditor.mnuBPCopyClick(Sender: TObject);
1090var
1091 ce: TCustomEdit;
1092
1093begin
1094 ce := GetPopupControl;
1095 if assigned(ce) then
1096 ce.CopyToClipboard;
1097end;
1098
1099procedure TfrmTemplateFieldEditor.mnuBPPasteClick(Sender: TObject);
1100var
1101 ce: TCustomEdit;
1102
1103begin
1104 ce := GetPopupControl;
1105 if assigned(ce) then
1106 ce.SelText := Clipboard.AsText;
1107end;
1108
1109procedure TfrmTemplateFieldEditor.mnuBPSelectAllClick(Sender: TObject);
1110var
1111 ce: TCustomEdit;
1112
1113begin
1114 ce := GetPopupControl;
1115 if assigned(ce) then
1116 ce.SelectAll;
1117end;
1118
1119procedure TfrmTemplateFieldEditor.mnuBPCheckGrammarClick(Sender: TObject);
1120var
1121 ce: TCustomEdit;
1122
1123begin
1124 ce := GetPopupControl;
1125 if(assigned(ce) and (ce is TRichEdit)) then
1126 GrammarCheckForControl(TRichEdit(ce));
1127end;
1128
1129procedure TfrmTemplateFieldEditor.mnuBPSpellCheckClick(Sender: TObject);
1130var
1131 ce: TCustomEdit;
1132
1133begin
1134 ce := GetPopupControl;
1135 if(assigned(ce) and (ce is TRichEdit)) then
1136 SpellCheckForControl(TRichEdit(ce), Sender = popNoteMemoSpellOpenSource); //WordVisTA@SK_Arora@HealthSevak to implement OpenSource SpellCheck Engine
1137end;
1138
1139procedure TfrmTemplateFieldEditor.cbSepLinesClick(Sender: TObject);
1140begin
1141 if((not FUpdating) and (assigned(FFld))) then
1142 begin
1143 FFld.SepLines := cbSepLines.Checked;
1144 cbSepLines.Checked := FFld.SepLines;
1145 end;
1146end;
1147
1148procedure TfrmTemplateFieldEditor.edtpopControlEnter(Sender: TObject);
1149begin
1150 popText.PopupComponent := TComponent(Sender);
1151 if assigned(frmTemplateFields) then
1152 begin
1153 if ((Sender = reItems) or (Sender = edtDefault)) then
1154 begin
1155 frmTemplateFields.btnInsert.Enabled := TRUE;
1156 if Sender = reItems then
1157 frmTemplateFields.re := reItems
1158 else
1159 frmTemplateFields.re := edtDefault;
1160 end
1161 else
1162 frmTemplateFields.btnInsert.Enabled := FALSE;
1163 end;
1164end;
1165
1166procedure TfrmTemplateFieldEditor.cbxObjsKeyDown(Sender: TObject;
1167 var Key: Word; Shift: TShiftState);
1168begin
1169 if(Key = VK_DELETE) and btnDelete.Enabled then
1170 mnuDeleteClick(btnDelete);
1171end;
1172
1173procedure TfrmTemplateFieldEditor.edtTextLenChange(Sender: TObject);
1174var
1175 v: integer;
1176
1177begin
1178 EnsureText(edtTextLen, udTextLen);
1179 if((not FUpdating) and (assigned(FFld)) and (FFld.FldType in EditLenTypes)) then
1180 begin
1181 FFld.TextLen := udTextLen.Position;
1182 udTextLen.Position := FFld.TextLen;
1183 if FFld.FldType = dftEditBox then
1184 begin
1185 v := udTextLen.Position;
1186 if udLen.Position > v then
1187 udLen.Position := v;
1188 end;
1189 end;
1190end;
1191
1192procedure TfrmTemplateFieldEditor.edtDefNumChange(Sender: TObject);
1193var
1194 v: integer;
1195
1196begin
1197 EnsureText(edtDefNum, udDefNum);
1198 if((not FUpdating) and (assigned(FFld)) and (FFld.FldType = dftNumber)) then
1199 begin
1200 FFld.EditDefault := IntToStr(udDefNum.Position);
1201 udDefNum.Position := StrToIntDef(FFld.EditDefault, 0);
1202 v := udDefNum.Position;
1203 if udMinVal.Position > v then
1204 udMinVal.Position := v;
1205 if udMaxVal.Position < v then
1206 udMaxVal.Position := v;
1207 end;
1208end;
1209
1210procedure TfrmTemplateFieldEditor.edtMinValChange(Sender: TObject);
1211var
1212 v: integer;
1213
1214begin
1215 EnsureText(edtMinVal, udMinVal);
1216 if((not FUpdating) and (assigned(FFld)) and (FFld.FldType = dftNumber)) then
1217 begin
1218 FFld.MinVal := udMinVal.Position;
1219 udMinVal.Position := FFld.MinVal;
1220 v := udMinVal.Position;
1221 if udDefNum.Position < v then
1222 udDefNum.Position := v;
1223 if udMaxVal.Position < v then
1224 udMaxVal.Position := v;
1225 end;
1226end;
1227
1228procedure TfrmTemplateFieldEditor.edtMaxValChange(Sender: TObject);
1229var
1230 v: integer;
1231
1232begin
1233 EnsureText(edtMaxVal, udMaxVal);
1234 if((not FUpdating) and (assigned(FFld)) and (FFld.FldType = dftNumber)) then
1235 begin
1236 FFld.MaxVal := udMaxVal.Position;
1237 udMaxVal.Position := FFld.MaxVal;
1238 v := udMaxVal.Position;
1239 if udDefNum.Position > v then
1240 udDefNum.Position := v;
1241 if udMinVal.Position > v then
1242 udMinVal.Position := v;
1243 end;
1244end;
1245
1246procedure TfrmTemplateFieldEditor.edtIncChange(Sender: TObject);
1247begin
1248 EnsureText(edtInc, udInc);
1249 if((not FUpdating) and (assigned(FFld)) and (FFld.FldType = dftNumber)) then
1250 begin
1251 FFld.Increment := udInc.Position;
1252 udInc.Position := FFld.Increment;
1253 end;
1254end;
1255
1256procedure TfrmTemplateFieldEditor.edtURLChange(Sender: TObject);
1257begin
1258 if((not FUpdating) and (assigned(FFld)) and (FFld.FldType = dftHyperlink)) then
1259 begin
1260 FFld.URL := edtURL.Text;
1261 edtURL.Text := FFld.URL;
1262 end;
1263end;
1264
1265procedure TfrmTemplateFieldEditor.edtPadChange(Sender: TObject);
1266begin
1267 EnsureText(edtPad, udPad);
1268 if((not FUpdating) and (assigned(FFld))) then
1269 begin
1270 FFld.Pad := udPad.Position;
1271 udPad.Position := FFld.Pad;
1272 end;
1273end;
1274
1275procedure TfrmTemplateFieldEditor.edtIndentChange(Sender: TObject);
1276begin
1277 EnsureText(edtIndent, udIndent);
1278 if((not FUpdating) and (assigned(FFld))) then
1279 begin
1280 FFld.Indent := udIndent.Position;
1281 udIndent.Position := FFld.Indent;
1282 end;
1283end;
1284
1285procedure TfrmTemplateFieldEditor.reNotesChange(Sender: TObject);
1286begin
1287 if((not FUpdating) and (assigned(FFld)) and FFld.CanModify) then
1288 FFld.Notes := reNotes.Lines.Text;
1289end;
1290
1291procedure TfrmTemplateFieldEditor.cbxDateTypeChange(Sender: TObject);
1292begin
1293 if((not FUpdating) and (assigned(FFld)) and (FFld.FldType = dftDate)) then
1294 begin
1295 if cbxDateType.ItemIndex >= 0 then
1296 FFld.DateType := TTmplFldDateType(cbxDateType.ItemIndex + 1)
1297 else
1298 FFld.DateType := dtDate;
1299 cbxDateType.SelectByID(TemplateFieldDateCodes[FFld.DateType]);
1300 end;
1301
1302end;
1303
1304procedure TfrmTemplateFieldEditor.cbExcludeClick(Sender: TObject);
1305begin
1306 if((not FUpdating) and (assigned(FFld))) then
1307 begin
1308 FFld.SepLines := cbExclude.Checked;
1309 cbExclude.Checked := FFld.SepLines;
1310 UpdateControls;
1311 end;
1312end;
1313
1314procedure TfrmTemplateFieldEditor.FormResize(Sender: TObject);
1315begin
1316 LimitEditWidth(reItems, 240);
1317 LimitEditWidth(reNotes, MAX_ENTRY_WIDTH);
1318end;
1319
1320procedure TfrmTemplateFieldEditor.reItemsResizeRequest(Sender: TObject;
1321 Rect: TRect);
1322var
1323 R: TRect;
1324
1325begin
1326 R := TRichEdit(Sender).ClientRect;
1327 if (FLastRect.Right <> R.Right) or
1328 (FLastRect.Bottom <> R.Bottom) or
1329 (FLastRect.Left <> R.Left) or
1330 (FLastRect.Top <> R.Top) then
1331 begin
1332 FLastRect := R;
1333 FormResize(Self);
1334 end;
1335end;
1336
1337procedure TfrmTemplateFieldEditor.reItemsSelectionChange(Sender: TObject);
1338var
1339 p: TPoint;
1340
1341begin
1342 if lblLine.Visible then
1343 begin
1344 p := reItems.CaretPos;
1345 lblLine.Caption := 'Line: ' + inttostr(p.y + 1);
1346 lblCol.Caption := 'Col: ' + inttostr(p.x + 1);
1347 end;
1348end;
1349
1350procedure TfrmTemplateFieldEditor.mnuInsertTemplateFieldClick(Sender: TObject);
1351var
1352 iCon: TCustomEdit;
1353 ShowButton: boolean;
1354begin
1355 iCon := GetPopupControl;
1356 if iCon <> nil then
1357 begin
1358 if iCon.Name <> ActiveControl.Name then
1359 begin
1360 ActiveControl := iCon;
1361 iCon.SelStart := iCon.SelLength;
1362 end;
1363 if (not assigned(frmTemplateFields)) then
1364 begin
1365 frmTemplateFields := TfrmTemplateFields.Create(Self);
1366 frmTemplateFields.Font := Font;
1367 end;
1368 ShowButton := False;
1369 if iCon = reItems then
1370 begin
1371 frmTemplateFields.re := reItems;
1372 ShowButton := TRUE;
1373 end
1374 else if iCon = edtDefault then
1375 begin
1376 frmTemplateFields.re := edtDefault;
1377 ShowButton := TRUE;
1378 end;
1379 frmTemplateFields.btnInsert.Enabled := ShowButton;
1380
1381 frmTemplateFields.Show;
1382 end
1383
1384end;
1385
1386procedure TfrmTemplateFieldEditor.ControlExit(Sender: TObject);
1387begin
1388 if assigned(frmTemplateFields) then
1389 frmTemplateFields.btnInsert.Enabled := FALSE;
1390end;
1391
1392procedure TfrmTemplateFieldEditor.reNotesKeyUp(Sender: TObject;
1393 var Key: Word; Shift: TShiftState);
1394begin
1395 if (Key = VK_TAB) then
1396 begin
1397 if ssShift in Shift then
1398 begin
1399 FindNextControl(Sender as TWinControl, False, True, False).SetFocus; //previous control
1400 Key := 0;
1401 end
1402 else if ssCtrl in Shift then
1403 begin
1404 FindNextControl(Sender as TWinControl, True, True, False).SetFocus; //next control
1405 Key := 0;
1406 end;
1407 end;
1408 if (key = VK_ESCAPE) then begin
1409 FindNextControl(Sender as TWinControl, False, True, False).SetFocus; //previous control
1410 key := 0;
1411 end;
1412end;
1413
1414end.
Note: See TracBrowser for help on using the repository browser.