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
> 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