Subject Re: Masking problem with TDateTime field
Author mspencewasunavailable
--- In IBObjects@yahoogroups.com, "computacionbariloche"
<computacionbariloche@...> wrote:
> --- In IBObjects@yahoogroups.com, Helen Borrie <helebor@> wrote:
> >
> > At 07:08 AM 17/08/2006, you wrote:
> > >I have a TDBEdit connected to an IBOQuery field that's a
TDateTime.
> > >When this field gets displayed, I get a validation error because
> > >there's some strange interaction between whatever formats the
field
> > >and the masking stuff.
> > >
> > >For instance, if I use today's date (8/16/2006), then the fact
that
> > >there's no leading zero seems shift things over, so that when
the
> > >data gets copied into TDBEdit.Text behind the scenes, it comes
out
> > >as 8//6//006.
> > >
> > >If I then put the cursor on the field and give it focus, the
text
> > >immediately changes to 8/16/2006 and all is well.
> > >
> > >Naturally, I can't reproduce this in an isolated case, it only
> > >happens when the whole big ugly application is running. I
suspect
> > >it has to do with the fact that this field gets changed via a
> > >different query and the one that's being used for display gets
> > >refreshed, but I can't prove it yet.
> > >
> > >Has anyone ever seen anything like this?
> >
> > It sounds as though the data might be stored in some string
type,
> > rather than a date/time type.
> >
> > Helen
> >
>
>
> I think the problem is in the field's mask or the control's mask
>
> Dany

It looks to me like the data is wrong. Maybe it shouldn't use the
Windows short date format, but should be made to match the input
mask (although this'd be a real pain to write).

Here's the complete stack from the OnChange event handler, when the
data gets put into the field. If I change the Windows short date to
MM/dd/yyyy, so that there's a leading 0 (08/16/2006), then
everything's fine.

When the short date is M/d/yyyy (evidently the default) it seems
that the string passed in is 8/16/2005 and isn't really lining up
with the mask. The stack frame marked ">>>>>>>>>>>>" below executes
this line:

EditText := FDataLink.Field.DisplayText;

It appears to me that when FDataLink.Field.DisplayText is the same
length as the mask, then everything's ok, but when it's missing the
leading 0 on the month, it winds up in the wrong place. I expect
9/1/2006 will cause a different sort of issue, which is why I'm not
sure what the best fix would be. I'm hoping this information might
ring a bell for someone who's more familiar with the code involved.


(Hmmmm. Googles for TDBEdit short date...).

Ah. The workaround appears to be to set the Delphi global
ShortDateFormat := 'MM/dd/yyyy' at program startup, overriding the
system setting. Didn't even know about that until this minute.

(Tries it out.) Yes, that works fine. Next time this comes up,
you'll know what to say <g>.


Anyway, here's the traceback:

TfrmCompleteWork.dbEdDateChange($2D7AF0C)
TCustomEdit.Change
TDBEdit.Change
TCustomEdit.CNCommand((48401, 2118, 768, 7276614, 0))
TControl.WndProc((48401, 50333766, 7276614, 0, 2118, 768, 2118, 111,
0, 0))
TWinControl.WndProc((48401, 50333766, 7276614, 0, 2118, 768, 2118,
111, 0, 0))
TControl.Perform(48401,50333766,7276614)
DoControlMsg(7276614,(no value))
TWinControl.WMCommand((273, 2118, 768, 7276614, 0))
TControl.WndProc((273, 50333766, 7276614, 0, 2118, 768, 2118, 111,
0, 0))
TWinControl.WndProc((273, 50333766, 7276614, 0, 2118, 768, 2118,
111, 0, 0))
TWinControl.MainWndProc((273, 50333766, 7276614, 0, 2118, 768, 2118,
111, 0, 0))
:0042bd4a StdWndProc + $16
:77d48734 user32.GetDC + 0x6d
:77d48816 ; C:\WINDOWS\system32\user32.dll
:77d4b4c0 ; C:\WINDOWS\system32\user32.dll
:77d4b50c ; C:\WINDOWS\system32\user32.dll
:7c90eae3 ntdll.KiUserCallbackDispatcher + 0x13
:77d4b903 user32.SendMessageW + 0x49
:773f25f5 ; C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-
Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\comctl32.dll
:773f3794 ; C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-
Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\comctl32.dll
:773f382a ; C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-
Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\comctl32.dll
:773f3bfe ; C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-
Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\comctl32.dll
:77d48734 user32.GetDC + 0x6d
:77d48816 ; C:\WINDOWS\system32\user32.dll
:77d4b4c0 ; C:\WINDOWS\system32\user32.dll
:77d4e871 user32.MonitorFromPoint + 0xe2
:7c90eae3 ntdll.KiUserCallbackDispatcher + 0x13
:77d4e905 user32.CallWindowProcA + 0x1b
TWinControl.DefaultHandler((no value))
TCustomEdit.DefaultHandler((no value))
TControl.WndProc((12, 0, 46964444, 0, 0, 0, 40668, 716, 0, 0))
TWinControl.WndProc((12, 0, 46964444, 0, 0, 0, 40668, 716, 0, 0))
TControl.Perform(12,0,46964444)
TControl.SetTextBuf('8/16/2006')
TCustomMaskEdit.SetEditText('8/16/2006')
>>>>>>>> TDBEdit.DataChange($2D7B1DC)
TFieldDataLink.RecordChanged(nil)
TDataLink.DataSetChanged
TDataLink.DataEvent(deDataSetChange,0)
TFieldDataLink.DataEvent(deDataSetChange,0)
TDataSource.NotifyLinkTypes(deDataSetChange,0,True)
TDataSource.NotifyDataLinks(deDataSetChange,0)
TDataSource.DataEvent(deDataSetChange,0)
TDataSet.DataEvent(deDataSetChange,0)
TDataSet.Resync([rmExact..rmCenter])
TIBODataset.Resync([rmExact..rmCenter])
TDataSet.GotoBookmark($2CC9FA8)
TDataSet.SetBookmarkStr('0000910000005E1B0000')
TIBODataset.GotoCurrent($2D72330)
TfrmCompleteWork.LockSelectPage
TfrmCompleteWork.setControlLocks
TSimpleEditDialogForm.timerEvent
TBaseSimpleEditDialog.setControlLocks
TCompleteWorkDialog.setControlLocks
TBaseSimpleEditDialog.timerEvent
TCompleteWorkDialog.timerEvent
TTimerChain.Exec
TfrmCustA.TimerEvent($2327CF0)
TTimer.Timer
TTimer.WndProc((275, 1, 0, 0, 1, 0, 0, 0, 0, 0))
:0042bd4a StdWndProc + $16
:77d48734 user32.GetDC + 0x6d
:77d48816 ; C:\WINDOWS\system32\user32.dll
:77d489cd ; C:\WINDOWS\system32\user32.dll
:77d496c7 user32.DispatchMessageA + 0xf
TApplication.ProcessMessage((7735280, 275, 1, 0, 141341046, (1204,
155)))
TApplication.HandleMessage
TCustomForm.ShowModal
TBaseSimpleEditDialog.showIt
TCompleteWork.getChoices
TCompleteWork.completeWork(0)
TCustomerRoutes.completeWork(0)
TfrmCustA.FormShow($2320F88)
TCustomForm.DoShow
TCustomForm.CMShowingChanged((45081, 0, 0, 0, 0, 0, 0, 0, 0, 0))
TControl.WndProc((45081, 0, 0, 0, 0, 0, 0, 0, 0, 0))
TWinControl.WndProc((45081, 0, 0, 0, 0, 0, 0, 0, 0, 0))
TCustomForm.WndProc((45081, 0, 0, 0, 0, 0, 0, 0, 0, 0))
TControl.Perform(45081,0,0)
TWinControl.UpdateShowing
TWinControl.UpdateControlState
TWinControl.CMVisibleChanged((45067, 1, 0, 0, 1, 0, 0, 0, 0, 0))
TControl.WndProc((45067, 1, 0, 0, 1, 0, 0, 0, 0, 0))
TWinControl.WndProc((45067, 1, 0, 0, 1, 0, 0, 0, 0, 0))
TCustomForm.WndProc((45067, 1, 0, 0, 1, 0, 0, 0, 0, 0))
TControl.Perform(45067,1,0)
TControl.SetVisible(True)
TCustomForm.SetVisible(True)
TCustomForm.Show
runCUSTA(4,1,0)
TfrmMain.ActionExecute($2302998)
:0042b08a TBasicAction.Execute + $12
TCustomAction.Execute
:0042af60 TBasicActionLink.Execute + $18
TCustomActionMenuBar.TrackMenu
TCustomActionMainMenuBar.TrackMenu
TCustomActionMenuBar.CMItemClicked((46083, 0, $22FEA24, 0))
TControl.WndProc((46083, 0, 36694564, 0, 0, 0, 59940, 559, 0, 0))
TWinControl.WndProc((46083, 0, 36694564, 0, 0, 0, 59940, 559, 0, 0))
TCustomActionMenuBar.WndProc((46083, 0, 36694564, 0, 0, 0, 59940,
559, 0, 0))
TWinControl.MainWndProc((46083, 0, 36694564, 0, 0, 0, 59940, 559, 0,
0))
:0042bd4a StdWndProc + $16
:77d48734 user32.GetDC + 0x6d
:77d48816 ; C:\WINDOWS\system32\user32.dll
:77d489cd ; C:\WINDOWS\system32\user32.dll
:77d496c7 user32.DispatchMessageA + 0xf
TApplication.ProcessMessage((7866334, 46083, 0, 36694564, 141320953,
(84, 58)))
TApplication.HandleMessage
TApplication.Run
accountrixxp
:7c816d4f kernel32.RegisterWaitForInputIdle + 0x49