View Issue Details

IDProjectCategoryView StatusLast Update
0001676JEDI VCL00 JVCL Componentspublic2004-04-22 03:01
ReporteranonymousAssigned Touser72 
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0001676: JvToolEdit-TJvDateEdit
DescriptionIf 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;

TagsNo tags attached.

Activities

user72

2004-04-22 00:13

  ~0003985

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?

anonymous

2004-04-22 02:21

viewer   ~0003995

Of course it's a nice way to solve it, increasing the features of the module.
Fine for me.

user72

2004-04-22 03:01

  ~0003996

Fixed in CVS

Issue History

Date Modified Username Field Change
2004-04-21 01:33 anonymous New Issue
2004-04-22 00:13 user72 Note Added: 0003985
2004-04-22 00:14 user72 Status new => feedback
2004-04-22 02:21 anonymous Note Added: 0003995
2004-04-22 03:01 user72 Status feedback => resolved
2004-04-22 03:01 user72 Resolution open => fixed
2004-04-22 03:01 user72 Assigned To => user72
2004-04-22 03:01 user72 Note Added: 0003996