BateDays for TDateTimePicker? [英] BoldDays for TDateTimePicker?

查看:340
本文介绍了BateDays for TDateTimePicker?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Delphi7,我想大胆的说一些 TDateTimePicker 控件的日子。

I'm using Delphi7 and I'd like to bold some days of a TDateTimePicker control.

我读过,原来它是 TMonthCalendar 的后代,因此应该是可能的。

I've read that, originally, it's a descendant of TMonthCalendar, thus it should be possible.

ve也找到一些示例代码,但它在C#:
http://social.msdn.microsoft.com/Forums/en/winforms/thread/03527023-694d-41ab-bffb-18c59fca1fda

I've also found some example code, but it's in C#: http://social.msdn.microsoft.com/Forums/en/winforms/thread/03527023-694d-41ab-bffb-18c59fca1fda

请注意,我不想使用任何第三方 DateTimePicker 控件,我想留下标准的。

Please note that I don't want to use any third party DateTimePicker controls, I'd like to stay with the standard one.

推荐答案

你是对和错的: - )

You are both right and wrong :-)

看到:
http://www.experts-exchange.com/Programming/System /Windows__Programming/MFC/Q_23927552.html

你是对的,你不能在XP下设置BoldDays。
但是你错了,因为在Vista / Win7下可以!

You are right that you can't set BoldDays under XP. But you are wrong because under Vista/Win7 you can!

这是修改后的代码:

procedure TForm1.DateTimePicker1DropDown(Sender: TObject);
const
  DTM_GETMCSTYLE = (DTM_FIRST + 12);
  DTM_SETMCSTYLE = (DTM_FIRST + 11);
  MCS_NOTRAILINGDATES = $0040;
  MCS_SHORTDAYSOFWEEK = $0080;
  MCS_NOSELCHANGEONNAV = $0100;
var
  monthCalHandle: THandle;
  boldDates: array[0..2] of integer;
  style, prevstyle: LResult;
begin
  style := SendMessage(DateTimePicker1.Handle, DTM_GETMCSTYLE, 0, 0);
  style := style or MCS_DAYSTATE; //or MCS_NOSELCHANGEONNAV or MCS_WEEKNUMBERS;
  prevstyle := SendMessage(DateTimePicker1.Handle, DTM_SETMCSTYLE, 0, style);

  monthCalHandle := SendMessage(dateTimePicker1.Handle, DTM_GETMONTHCAL, 0, 0);

  boldDates[0]:=$5a5a5a;
  boldDates[1]:=$5a5a5a;
  boldDates[2]:=$5a5a5a;
  SendMessage(monthCalHandle, MCM_SETDAYSTATE, 3, integer(@boldDates));
end;

注意:请确保将vista清单添加到文件中,否则不会工作!

常数来自一个更新的commctrl.h文件,在这里找到:
http://www.koders.com/cpp/fid6A6537D52B537D0920D7A760D2073F7B65ADE310.aspx?s=WM_CAP_DRIVER_CONNECT

The constants are from an updated commctrl.h file, found here: http://www.koders.com/cpp/fid6A6537D52B537D0920D7A760D2073F7B65ADE310.aspx?s=WM_CAP_DRIVER_CONNECT

感谢您的帮助,您带我到解决方案! : - )

Thanks for the help, you lead me to the solution! :-)

这篇关于BateDays for TDateTimePicker?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆