Forum > LCL

TDateTime picker - how to determine if first or last part is focused?

(1/3) > >>

korba812:
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?

Nicole:
Not sure, what you mean exactly.
Do you think, you can post some screenshots?

I address
DateTimePicker1.Time
and
DateTimePicker1.Date

KodeZwerg:

--- Quote from: korba812 on September 21, 2022, 09:03:33 pm ---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?

--- End quote ---
you should not check for (1), use proper names!
dtpYear, dtpDay, dtpMonth, dtpHour, dtpMinute, dtpSecond, dtpMiliSec

does that answer your question?

korba812:
Thanks for the answers, but I want to know if first or last part of date or time is highlighted. See attached image.

Zoran:

--- Quote from: korba812 on September 21, 2022, 09:03:33 pm ---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?

--- End quote ---

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.

Navigation

[0] Message Index

[#] Next page

Go to full version