Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TDateTimePicker- to highlight dates

277 views
Skip to first unread message

Anatoly

unread,
May 18, 2006, 5:22:16 AM5/18/06
to
Hi!

I need to be able to highlight some dates when the calendar drops down
after a mouse click.

I have found some useful information applicable to component
TMonthCalendar. It is possible to send it a message "MCM_SETDAYSTATE"
the following way:
SendMessage(MonthCalendar1.Handle, MCM_SETDAYSTATE, 3, Longint(@mds));

"mds" is an array that is initialized the following way:
var
mds: array[1..3] of MONTHDAYSTATE;

mds[1] := mds[1] or (1 shl 29);
mds[2] := mds[1] or (1 shl 2);
mds[3] := mds[1] or (1 shl 2);

The result is that the 3-rd of the current and then next months and the
30-ths of the previous month are highlighted with bold font. So far so
good- it works for TMonthCalendar.

Problem: when I try to do the same with TDateTimePicker in its DropDown
event then nothing happens. I get its handle and check that it's not
null and send a message:

CalendarHandle := DateTime_GetMonthCal(DateTimePicker1.Handle);
SendMessage(CalendarHandle, MCM_SETDAYSTATE, 3, Longint(@mds));

Then nothing happens.

Question:
1. How can I highlight the dates I need with a different font (or
color?)in TDateTimePicker?
2. Are there any other way of highlighting that can be used instead of
the one I've been thinking of?

Best regards,
Anatoly

Remy Lebeau (TeamB)

unread,
May 18, 2006, 2:39:24 PM5/18/06
to

"Anatoly" <anat...@gmail.com> wrote in message
news:446c3cc7$1...@newsgroups.borland.com...

> I need to be able to highlight some dates when the calendar
> drops down after a mouse click.

Date/Time Picker controls do not natively support what you are asking for.
That is a Win32 API limitation, not a VCL limitation.

> when I try to do the same with TDateTimePicker in its
> DropDown event then nothing happens.

You cannot send MCM messages to a Date/Time Picker control. Date/Time
Picker controls use DTM messages instead. There is no DTM message for
setting bold days.

> CalendarHandle := DateTime_GetMonthCal(DateTimePicker1.Handle);
> SendMessage(CalendarHandle, MCM_SETDAYSTATE, 3, Longint(@mds));
>
> Then nothing happens.

If you look at the return value of SendMessage(), you will see that it
always returns 0, indicating that the MCM_SETDAYSTATE message is failing.

> How can I highlight the dates I need with a different font (or color?)in
TDateTimePicker?

As far as I know, you can't.

> Are there any other way of highlighting that can be used instead
> of the one I've been thinking of?

The only way is to either use a TMonthCalendar and show/hide it manually, or
else find a third-party Date/Time Picker that supports what you are asking
for.


Gambit


Justin Levene

unread,
Jun 9, 2006, 6:16:16 AM6/9/06
to
You can't do it because you must set MCS_DAYSTATE in the StyleEx when
creating a MonthCalendar. Microsoft decided, in all of their wisdom,
not do do this for the MonthCalendar in the DateTimePicker. It is a
Windows limitation, not a VCL one. As Windows is not Object Orientated
you can't override this, the only way would be to design a component
from scratch (I did this a few years ago but have lost the code, it also
allowed Nul dates as blank text, if you do one please keep me informed).

Justin

0 new messages