View Issue Details

IDProjectCategoryView StatusLast Update
0006067JEDI VCL00 JVCL Componentspublic2015-09-14 13:20
ReportertetarddAssigned Toobones 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.47 
Target VersionFixed in Version3.48 
Summary0006067: TJvDateTimePicker causes Exception when using NullDate
DescriptionThe following code (with a form with a simple TJvDateTimePicker and a TBUtton) causes an Exception (cannot set the date) when the button is clicked:

**********************************************************

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ComCtrls, JvExComCtrls,
  JvDateTimePicker;

type
  TForm22 = class(TForm)
    id_ExpEndDate: TJvDateTimePicker;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form22: TForm22;

implementation

{$R *.dfm}

procedure TForm22.FormCreate(Sender: TObject);
begin
     id_ExpEndDate.NullText := 'No date selected';
     id_ExpEndDate.NullDate := 0.0;
     id_ExpEndDate.MinDate := Date;
     id_ExpEndDate.DropDownDate := Date;
end;


procedure TForm22.Button1Click(Sender: TObject);
begin
     id_ExpEndDate.Date := id_ExpEndDate.NullDate;
end;

************************************

This is the code that I propose should be changed in TJvDateTimePicker:
function TJvDateTimePicker.MsgSetDateTime(Value: TSystemTime): Boolean;
var
  LNullText: string;
begin
  Result := inherited MsgSetDateTime(Value);
  
  (* Initial code:
     This is wrong because if the VCL's MsgSetDateTime reports an error, we will
      have an exception, and because the VCL's code does not know about
      NullDate, it will report an error.
      
  if FMsgSetDateTimeEmptyNullText then
    LNullText := ''
  else
    LNullText := FNullText;
  CheckNullValue(LNullText, Format, Kind, SystemTimeToDateTime(Value), NullDate);
  *)
  
  // Proposed changes by David Tetard:
  if not Result then
  begin
    if FMsgSetDateTimeEmptyNullText then
      LNullText := ''
    else
      LNullText := FNullText;
    Result := CheckNullValue(LNullText, Format, Kind,
      SystemTimeToDateTime(Value), NullDate);
  end;
end;
TagsNo tags attached.

Activities

2013-01-22 17:27

 

JvDateTimePicker.pas (13,207 bytes)

tetardd

2013-01-22 17:28

reporter   ~0020412

After some more testing, my solution was not entirely satisfactory. My last attachment is yet another proposed fix (see changed in code by looking for "Tetard").

obones

2013-12-13 12:15

administrator   ~0020808

This is now fixed in GIT

Issue History

Date Modified Username Field Change
2013-01-19 08:42 tetardd New Issue
2013-01-22 17:27 tetardd File Added: JvDateTimePicker.pas
2013-01-22 17:28 tetardd Note Added: 0020412
2013-12-13 10:40 obones Status new => acknowledged
2013-12-13 12:15 obones Note Added: 0020808
2013-12-13 12:15 obones Status acknowledged => resolved
2013-12-13 12:15 obones Fixed in Version => Daily / GIT
2013-12-13 12:15 obones Resolution open => fixed
2013-12-13 12:15 obones Assigned To => obones
2015-09-14 13:20 obones Fixed in Version Daily / GIT => 3.48