Delphi 5 TDateTimePicker Format

During add Delphi 5 compatibility to the Purchase Order calculation sample of HotXLS Delphi Excel Spreadsheet component, an error occurred while compiling under Delphi 5.

The line which set the date format of the TDateTimePicker control does not compile:

TDateTimePicker control of Delphi is a wrapper around a Microsoft control. It allows you to show the date in one of two formats (long and short), but in Delphi 5 and lower, it did not allow you to change the DateTime format. That’s because it uses the Windows date and time settings, not Delphi’s internal format variables like “ShortDateFormat”.

In Delphi 6 and later, you can use the Format property to change the display of date or time.

In Delphi 5 and earlier, you should use the DateTime_SetFormat function to set the format, this function in the “CommCtrl” unit, you should add CommCtrl to the “USES” column, otherwise, the DateTime_SetFormat won’t be recognized.

The fix for our sample project looks like this:

Author: losLab

Devoted to developing PDF and Spreadsheet developer library, including PDF creation, PDF manipulation, PDF rendering library, and Excel Spreadsheet creation & manipulation library.