Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0004651 [JEDI VCL] 00 JVCL Components tweak always 2009-01-08 05:27 2012-02-29 16:55
Reporter ZENsan View Status public  
Assigned To obones
Priority normal Resolution fixed  
Status resolved   Product Version Daily / GIT
Summary 0004651: TJvDBDatePicker
Description If 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 Information Unit: JvDateTimePicker.pas: Line 287

procedure TJvDateTimePicker.CNNotify(var Msg: TWMNotify);

...
      NM_KILLFOCUS:
        begin
          NullText := FKeepNullText;
          inherited;
        end;
      DTN_CLOSEUP:
        begin
        end
    else
      inherited;
    end;
...

If we just do not call DTN_CLOSUP notification to TDateTime control, then all goes fine and no conflicts for me.
Tags No tags attached.
Attached Files zip file icon DatePicker.zip [^] (1,206 bytes) 2009-04-30 15:22

- Relationships
related to 0005335resolvedAHUser Call Inherited in CNNotify TJvDateTimePicker missing 

-  Notes
(0015247)
ZENsan (reporter)
2009-01-15 08:10

Some news, guys?
(0015447)
obones (administrator)
2009-04-29 11:43

Please provide the zipped sources of a sample application showing this.
(0015505)
ZENsan (reporter)
2009-04-30 15:23

Just press arrow on DatePicker, and then click in any other place on the form (deactivate datepicker). I think it is not normal appereance.
(0015526)
ZENsan (reporter)
2009-05-18 17:01

Hello?
(0015788)
obones (administrator)
2009-07-08 15:47

Thanks, this is now in SVN
(0018083)
Arioch (developer)
2010-11-11 03:54

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.
(0018085)
Arioch (developer)
2010-11-11 04:08

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.
(0018086)
Arioch (developer)
2010-11-11 04:13

foreword - i modified example with

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

procedure TfrmMain.MDataAfterClose(DataSet: TDataSet);
begin
  showRows;
end;

procedure TfrmMain.MDataAfterDelete(DataSet: TDataSet);
begin
  showRows;
end;

procedure TfrmMain.MDataAfterInsert(DataSet: TDataSet);
begin
  showRows;
end;

procedure TfrmMain.MDataAfterOpen(DataSet: TDataSet);
begin
  showRows;
end;

procedure TfrmMain.MDataAfterScroll(DataSet: TDataSet);
begin
  showRows;
end;

procedure TfrmMain.MDataBeforeInsert(DataSet: TDataSet);
begin
  showRows;
end;

procedure TfrmMain.MDataNewRecord(DataSet: TDataSet);
begin
  showRows;
end;
====

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.
(0018087)
Arioch (developer)
2010-11-11 04:53

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.
(0018088)
Arioch (developer)
2010-11-11 05:03

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.
(0018089)
Arioch (developer)
2010-11-11 05:16

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 TDbf.sf.net 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.
(0018090)
Arioch (developer)
2010-11-11 05:25

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.
(0018091)
Arioch (developer)
2010-11-11 05:26

> If any, i think NullText is to be kept,
read: if in-spite all this NullText still be kept, then i think....
(0018093)
Arioch (developer)
2010-11-11 12:19

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 :-)
(0018189)
AHUser (developer)
2010-11-27 22:23

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: DatePicker.zip
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


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker