Hi.
I can check the currently highlighted part of TDateTimePicker with GetSelectedDateTimePart function, I can determine the type of first part with GetDateTimePartFromTextPart(1) function. But how can I check that the last part is highlighted?
Do I have to determine it from properties (Kind, HideDateTimePart, DateDisplayOreder, etc) or is there an easier solution?
First, as you can use GetDateTimePartFromTextPart, which is protected, you can also use GetSelectedDateTimePart, which is also protected. Perhaps that is all you need?
Also, about GetDateTimePartFromTextPart, are you sure that it returns what you need?
You should know that what GetDateTimePartFromTextPart(1) returns is not the first
visible part; this function is used internally and it serves well for what is needed there, but this might not be what you expect.
For example, when kind property is dtkTime, it will return some
date part (not time part, not dtpHour), even though it is not visible (which part exactly it returns, depends on DateDisplayOrder). So, GetDateTimePartFromTextPart(1) will never return dtpHour (and GetDateTimePartFromTextPart(4) will always return dtpHour, it does not matter if hour is displayed or not).
On the other hand, GetSelectedDateTimePart will always return the part which is currently selected.