Friday, May 8, 2009

How to Remove the "Today" Mark from the TDateTimePicker

The TDateTimePicker component displays a list box for entering dates or times. By design it displays the label "today" at the bottom of the control allowing a user to quickly select the today's date.

Here's how to remove the "today" marker from the TDateTimePicker. Handle the OnDropDown event as:

uses CommCtrl, ...

procedure TForm1.DateTimePicker1DropDown(Sender: TObject) ;
var
wnd: HWND;
style: Integer;
begin
wnd := DateTime_GetMonthCal(DateTimePicker1.Handle) ;
if wnd <> 0 then
begin
style := GetWindowLong(wnd, GWL_STYLE) ;
SetWindowLong(wnd, GWL_STYLE, style or MCS_NOTODAY or MCS_NOTODAYCIRCLE) ;
end;
end;

No comments: