How to hide the seconds in a TDateTimePicker (Views: 28)
Problem/Question/Abstract: I'm using a TDateTimePicker component to edit time values, but I don't need the seconds. Input of hours and minutes would be enough. Setting the time format in the control panel to "hh:mm" does this. But I would like to change any settings in the application to get the result. Answer: { ... } const date_format = 'yyyy MMM dd'; {year, short month, day format} L_time_format = 'HH:mm:ss'; {24-hour clock, hours, minutes and seconds} S_time_format = 'HH:mm'; {24-hour clock, hours, minutes} var fmt: string; begin fmt := L_time_format; {Was S_time_format} SendMessage(DateTimePickerTime.Handle, DTM_SETFORMATA, 0, Integer(fmt)); fmt := date_format; SendMessage(DateTimePickerDate.Handle, DTM_SETFORMATA, 0, Integer(fmt)); end; |