DateTimePicker 组件,C++ Builder 6

DateTimePicker component, C++ Builder 6

我应该怎么做才能在标记的 window 中用键盘输入年份?由于默认只允许箭头,不太方便

TDateTimePicker 只是标准 Win32 DTP control. The standard DTP control simply does not support the functionality you are asking for. The Year can only be set using the arrows when the control is expanded. See About Date and Time Picker Controls and About Month Calendar Controls 的薄包装,用于本机支持的键盘输入类型。

也就是说,您所要求的将要求您相应地手动访问选择器的下拉菜单 Month-Calendar control (see DTN_DROPDOWN and DTM_GETMONTHCAL) and then inject an Up-Down control directly into it where needed (not sure if there is an API to determine exactly where the calendar displays its current year, maybe MCM_GETCALENDARGRIDINFO or MCM_HITTEST can be used for that?), and then subclass the calendar to handle the UD control's UDN_DELTAPOS notification so you can update the calendar

付出很多却收获甚微。