Board index » cppbuilder » TDateTimePicker problem

TDateTimePicker problem

The problem is simple to reproduce (with BCB3). Drop a TDateTimePicker
onto a form and leave all properties at the default values. When the
form appears, click on the down button of the control, then click on it
again without selecting any date from the calendar. It causes an error
every time ("Invalid argument to date encode"). Is there a way to fix
it?

Thanks,

Jim

 

Re:TDateTimePicker problem


Hi Jim

there is the VCL FAQ2570C at http://www.borland.com/devsupport/bcppbuilder/faq/

Or you can inherit from the TDateTimePicker and override the CreateWnd method

void __fastcall TsDateSelector::CreateWnd()
{
  TDateTimePicker::CreateWnd();
  /* --- As FAQ 2570C
  In CreateWnd because we need the Handle */
  NMDATETIMECHANGE dtc;
  SYSTEMTIME now;
  GetSystemTime(&now);
  dtc.nmhdr.hwndFrom = Handle;
  dtc.nmhdr.idFrom = NULL;
  dtc.nmhdr.code = DTN_DATETIMECHANGE;
  dtc.dwFlags = GDT_VALID;
  dtc.st = now;
  Perform(WM_NOTIFY, NULL, (int)&dtc);
  /*------------------------------------------------------------------------*/

Quote
}

Re:TDateTimePicker problem


I had not noticed that before even though I use it often. Probably the
reason I have not noticed it is because I initialize the date to the
current date when the app is started. Just setting the date to any date at
runtime seems to fix the problem.
Quote
Jim Melsom wrote:
> The problem is simple to reproduce (with BCB3). Drop a TDateTimePicker
> onto a form and leave all properties at the default values. When the
> form appears, click on the down button of the control, then click on it
> again without selecting any date from the calendar. It causes an error
> every time ("Invalid argument to date encode"). Is there a way to fix
> it?

> Thanks,

> Jim

Other Threads