View Issue Details

IDProjectCategoryView StatusLast Update
0004651JEDI VCL00 JVCL Componentspublic2012-02-29 16:55
ReporterZENsanAssigned Toobones 
Status resolvedResolutionfixed 
Product VersionDaily / GIT 
Target VersionFixed in Version3.45 
Summary0004651: TJvDBDatePicker
DescriptionIf NullText <> '' then for NULL field if we just press arrow button and then lose focus from combobox - TDateTimeEdit raises exception that we need to be in ShowCheckboxes mode. To fix this issue I can suggest this code. Do not know if it is 100% correct, but it works.

Additional InformationUnit: JvDateTimePicker.pas: Line 287

procedure TJvDateTimePicker.CNNotify(var Msg: TWMNotify);

          NullText := FKeepNullText;

If we just do not call DTN_CLOSUP notification to TDateTime control, then all goes fine and no conflicts for me.
TagsNo tags attached.


related to 0005335 resolvedAHUser Call Inherited in CNNotify TJvDateTimePicker missing 



2009-01-15 08:10

reporter   ~0015247

Some news, guys?


2009-04-29 11:43

administrator   ~0015447

Please provide the zipped sources of a sample application showing this.

2009-04-30 15:22 (1,206 bytes)


2009-04-30 15:23

reporter   ~0015505

Just press arrow on DatePicker, and then click in any other place on the form (deactivate datepicker). I think it is not normal appereance.


2009-05-18 17:01

reporter   ~0015526



2009-07-08 15:47

administrator   ~0015788

Thanks, this is now in SVN


2010-11-11 03:54

developer   ~0018083

requires reconsidering.
Shoud be discussed either here or in NNTP or in wiki.

NNTP is comfort to discuss, but then has no WWW links to re-read.

at least this lead to 0005335, which is worse.
I told in comments there.


2010-11-11 04:08

developer   ~0018085

I'd re-state.

1) if this quick and dirty patch is to be made - it should be made in procedure TJvDBDateTimePicker.CNNotify not touching procedure TJvDateTimePicker.CNNotify nor touching any other component.

2) TJvDBDateTimePicker tries to outsmart Windows itself and VCL, especially with MemoryDataset.

2.1) MemoryDataset originated in ancient times of 16-bit Delphi1/Windows3 and since RxLib strived to support all Delphi versions through (from 16-bit 1 to 32-bit D5 oficially and to D7 unofficially when merged with JVCL) and to my experience is itsef quick-and-dirty (or maybe obsolete-hence-dirty). I was never sure it would always act *exactly* like other datasets do.

So - at least in this demo - the component just asks for trouble. And should deal with it self.


2010-11-11 04:13

developer   ~0018086

foreword - i modified example with

procedure TfrmMain.showRows;
  Caption := IntToStr(MData.RecordCount) +' rows';

procedure TfrmMain.MDataAfterClose(DataSet: TDataSet);

procedure TfrmMain.MDataAfterDelete(DataSet: TDataSet);

procedure TfrmMain.MDataAfterInsert(DataSet: TDataSet);

procedure TfrmMain.MDataAfterOpen(DataSet: TDataSet);

procedure TfrmMain.MDataAfterScroll(DataSet: TDataSet);

procedure TfrmMain.MDataBeforeInsert(DataSet: TDataSet);

procedure TfrmMain.MDataNewRecord(DataSet: TDataSet);

Thus i hope to always know how many rows in the table.
Surprise - they always zero.
Events do fire. When i open drop-down picker, i see events fired: BeforeInsert, OnNewRecord, AfterInsert, AfterScroll
So seems the picker tries to silently insert new row into empty dataset.
However MemoryDataSet.RecordsCount still remains zero - empty table.


2010-11-11 04:53

developer   ~0018087

Now, right in the IDE toggle MemoryDataset.Active - you would see that text in the Picker changes.
If table is closed - it just shows Now; if table is opened - though Empty - it contains placeholder, that very NullText <> ''

Is it correct to assume NULL value, when there is no single row in the dataset ???
Is it bug in the Picker, in the Dataset or in both ?


Now, looking at TJvDateTimePicker.CheckNullValue
 1) Is it okay, when TJvDateTimePicker.NullText is set and TJvDateTimePicker.CheckNullDate is not ?
 2) Is TJvDateTimePicker.CheckNullValue supposed not only to override date format (via SendMessage) but also the time itself in windows control?
 3) it is done in CNNotify only if ParseInput is set to True. Overall Peter's comments on that feature in file header are shocking a bit. The feature was added with arge restriction and for knowledgable person that would manually control all that. Peter probably was the person, yet TJvDBDatePicker is certainy not.


float value 0.0 corresponds to Delphi's TDateTime value of 31-dec-1899
Set NullDate to somethign different, and the demo behaviour radicaly changes.
1) it does no more through the exception on NullText value
2) it does through exception on 31-dec-1899 value
3) suddenly! you can change date via arrows - left/right select day/month/year and up/down adjust value. Select date like NullDate + 1 year, then using arrows try to decrement year. You'd expect to get Nulldate then, but you'll get 31-dec-1899 instead.

So this issue is not NullText-related but is NullDate- and DataSet-related.
NullText is having two functions: to contain the text and as flag enablling/disabling the functionality. That confused topic starter.


2010-11-11 05:03

developer   ~0018088

The DatePicker is not our toy, but is a wrapper arounf Microsoft's control. What are it's limitations ?

1) it provides for NULL value, but not in a way of custom text. MS uses checkbox for it.
See VCL help for TDateTimePicker.ShowCheckbox and MSDN for DTS_SHOWNONE
2) it only provides for standard, Windows-generated text unless you allow free-form user typing in.
See VCL help for TDateTimePicker.ParseInput and MSDN for DTS_APPCANPARSE

Stepping aside those rules seems to make control into non-standard, unpredictable behaviour. Or related controls.


2010-11-11 05:16

developer   ~0018089

JvDBDateTimePicker is to acknowledge NULL value of datasets' fields.
1) it should check TField.Required and either set TDateTimePicker.ShowCheckbox := not TField.Required or refuse to operate to nullable fields.
2) it should tell empty field and field with date 0.0 (aka 31-dec-1899)
2.1) i don't know why TField.AsDateTime can be read on NULL field at all. To me it should just through exception, not making NULL == 0.0
 Again, this seems to be a bug either in VCL TField class, or in JVCL TJvMemoryDataset. Or maybe that is standard Borland's design of VCL ? i don't remember it today. Few years ago when i messed with project, i'd answer :-)
 Probably MemoryDataset just can't make difference between NULL and 0 at all.
3) probably JvDBDateTimePicker should avoid reading from empty datasets and plus to it, probably JvMemoryDataset should also prohibit it. I can see some reasoning behind automagical insertion of new row into table, when i edit date and write some value into nowhere. But inserting row when i am just reading? nonsense, isn't it ?

Maybe NullText is to be never allowed on DBDatePicker in 1st place.
Maybe even if someone clarified a the questions above and fixed all those troubles, it would still be fragie and lead to unexpected behaviour between Microsoft CommCtrl and BorlandVCL and JVCL and all their sudden interactions. At least i was tracing them for hour and half and then thought about them and made more tests and... and still aint sure.

OKay i'm falling asleep now.


2010-11-11 05:25

developer   ~0018090

If any, i think NullText is to be kept, then it should just be wired to TField.DisplayText
DB-aware controls should not decide such things on themselves, but rather should obey to TDataSet and such.

Same way, DTP's OnUserInput should be routed to TField.OnSetText.

all-in-all that for me asks for decoupling, so NullText and OnUserInput be not public in JvDBDateTimePicker. Thus, it should not be derived directly from JV-DTP, but they rather hard common 3rd ancestor, like JvCustomDTP, with the prperties kept protected and not reachable for application developer.


2010-11-11 05:26

developer   ~0018091

> If any, i think NullText is to be kept,
read: if in-spite all this NullText still be kept, then i think....


2010-11-11 12:19

developer   ~0018093

one more snarling...

bug was reported for certain situation "If NullText <> '' then"
so this destructive so-called fix also should at very least be deployed into that situations and not be always active.

PS: that's when imperative languages lack Guards and tail recursion and only have goto for optimization :-)


2010-11-27 22:23

developer   ~0018189

Fixed in svn revision 12914.

The inherited is back and I fixed another NullText bug when the user clicks outside of the popup calendar and Date=NullDate the 1899-12-30 was displayed instead of NullText.

Issue History

Date Modified Username Field Change
2009-01-08 05:27 ZENsan New Issue
2009-01-15 08:10 ZENsan Note Added: 0015247
2009-02-02 01:22 obones Status new => acknowledged
2009-04-29 11:43 obones Note Added: 0015447
2009-04-29 11:43 obones Status acknowledged => feedback
2009-04-30 15:22 ZENsan File Added:
2009-04-30 15:23 ZENsan Note Added: 0015505
2009-05-18 17:01 ZENsan Note Added: 0015526
2009-07-06 14:11 obones Status feedback => acknowledged
2009-07-08 15:47 obones Note Added: 0015788
2009-07-08 15:47 obones Status acknowledged => resolved
2009-07-08 15:47 obones Fixed in Version => Daily / SVN
2009-07-08 15:47 obones Resolution open => fixed
2009-07-08 15:47 obones Assigned To => obones
2010-10-08 16:38 obones Relationship added related to 0005335
2010-11-11 03:54 Arioch Note Added: 0018083
2010-11-11 03:54 Arioch Status resolved => feedback
2010-11-11 03:54 Arioch Resolution fixed => reopened
2010-11-11 04:08 Arioch Note Added: 0018085
2010-11-11 04:13 Arioch Note Added: 0018086
2010-11-11 04:53 Arioch Note Added: 0018087
2010-11-11 05:03 Arioch Note Added: 0018088
2010-11-11 05:16 Arioch Note Added: 0018089
2010-11-11 05:25 Arioch Note Added: 0018090
2010-11-11 05:26 Arioch Note Added: 0018091
2010-11-11 12:19 Arioch Note Added: 0018093
2010-11-27 22:23 AHUser Note Added: 0018189
2010-11-27 22:23 AHUser Status feedback => resolved
2010-11-27 22:23 AHUser Fixed in Version 3.38 => Daily / SVN
2010-11-27 22:23 AHUser Resolution reopened => fixed
2012-02-29 16:55 obones Fixed in Version Daily / SVN => 3.45