View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001676 | JEDI VCL | 00 JVCL Components | public | 2004-04-21 01:33 | 2004-04-22 03:01 |
Reporter | anonymous | Assigned To | user72 | ||
Priority | normal | Severity | feature | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | |||||
Target Version | Fixed in Version | ||||
Summary | 0001676: JvToolEdit-TJvDateEdit | ||||
Description | If the user imput a bad number in the date (like 13 for the month) the module raise an error. It would be be nice to trap it directly in the unit and avoid that. Suggestion: procedure TJvCustomDateEdit.CheckValidDate; begin if TextStored then try FFormatting := True; try SetDate(StrToDateFmt(FDateFormat, Text)); finally FFormatting := False; end; except if CanFocus then begin MessageDlg('Wrong date format!', mtError, [mbOK], 0); SetFocus; end else raise; // really need it ? end; end; | ||||
Tags | No tags attached. | ||||
|
How about this: add a new event type: type TJvInvalidDateEvent = procedure(Sender: TObject; const DateString:string; var NewDate:TDateTime; var Accept:boolean) of object; add a new protected method to TJvCustomDateEdit: function DoInvalidDate(const DateString:string; var ANewDate:TDateTime):boolean;virtual; add a new protected event property: property OnInvalidDate: TJvInvalidDateEvent read FOnInvalidDate write FOnInvalidDate; change TJvCustomDateEdit.CheckValidDate to: procedure TJvCustomDateEdit.CheckValidDate; var ADate:TDateTime; begin if TextStored then try FFormatting := True; try SetDate(StrToDateFmt(FDateFormat, Text)); finally FFormatting := False; end; except if CanFocus then SetFocus; ADate := Self.Date; if DoInvalidDate(Text,ADate) then Self.Date := ADate else raise; end; end; publish OnInvalidDate in TJvDateEdit How about that? |
|
Of course it's a nice way to solve it, increasing the features of the module. Fine for me. |
|
Fixed in CVS |
Date Modified | Username | Field | Change |
---|---|---|---|
2004-04-21 01:33 | anonymous | New Issue | |
2004-04-22 00:13 |
|
Note Added: 0003985 | |
2004-04-22 00:14 |
|
Status | new => feedback |
2004-04-22 02:21 | anonymous | Note Added: 0003995 | |
2004-04-22 03:01 |
|
Status | feedback => resolved |
2004-04-22 03:01 |
|
Resolution | open => fixed |
2004-04-22 03:01 |
|
Assigned To | => user72 |
2004-04-22 03:01 |
|
Note Added: 0003996 |