如何自定义日历中DateTimePicker控件? [英] How to customize Calendar in DateTimePicker Control?

查看:520
本文介绍了如何自定义日历中DateTimePicker控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我觉得这个问题是简单明了。该图像波纹管是我目前的进展情况。

I think the question is simple and clear. The image bellow is my current progress.

由于你可以看到,定制版是我的扩展DateTimePicker控件。控制按钮的变化和边框颜色取决于聚焦值。该掉了下来日历是我想要的样式,接下来的事情。

As you can see, customized version is my extended DateTimePicker Control. The control changes button and border color depending on the Focused value. The dropped down calendar is the next thing I want to style.

我只是不知道从哪里开始,因为没有接缝是工作。我不会改变太多,至少边框颜色,字体颜色等...

I just don't know where to start because nothing seams to be working. I wouldn't change much at least border color, font color and etc...

推荐答案

您的非常的几个选项。下拉日历是一个MonthCalendar控件,当您单击再次被破坏的下拉按钮,当用户将其关闭通过DTP动态创建。的MonthCalendar是常用控件,内置于Windows,用C ++编写,并存储在COMCTL32.DLL。您的应用程序使用V6.0版本,存储在并排端缓存(C:\windows\winsxs)。 .NET类是只是一个包装,它不会改变它的外观和工作方式。

You have very few options. The drop-down calender is a MonthCalendar control, created dynamically by DTP when you click the dropdown button Destroyed again when the user dismisses it. MonthCalendar is one of the common controls, built into Windows, written in C++ and stored in comctl32.dll. Your app uses the v6.0 version, stored in the side-by-side cache (c:\windows\winsxs). The .NET class is just a wrapper, it doesn't change the way it looks or works.

值得注意的是,它改变了Windows版本之间有很大的,总有一些事情你要注意,这是在Windows非常明显的地方使用。这是一个用户曾经当他安装Windows进行交互的第一公共控制。而在任务栏上的时钟使用。的Windows 10是第一个版本不再存在,该Win8的外观和手感冷冻的,不可能永远再次发生变化。

Notable is that it changed a great deal between Windows versions, always something you have to watch out for, it is used in highly visible places in Windows. It is the first common control that a user ever interacts with when he installs Windows. And used in clock on the taskbar. Windows 10 is the first version that no longer does, the Win8 look-and-feel is frozen and unlikely to ever change again.

如前所述,动态创建下拉。您可以通过发送的 DTM_GETMONTHCAL消息,在下拉事件的事件处理函数中执行。在这一点上窗口句柄是有效的,但日历尚不可见,适当的时候,以修改它。

As noted, the dropdown is dynamically created. You can get a handle to the MonthCalendar window by sending the DTM_GETMONTHCAL message, do so in an event handler for the DropDown event. At that point the window handle is valid but the calendar not yet visible, the proper time to tinker with it.

在那里,您可以发送的 MCM邮件配置日历。正如你所知道的,非常纤薄采摘尽可能造型去。你必须MCM_SETCALENDARBORDER更改边框的厚度和MCM_SETCOLOR改变颜色。如果视觉风格渲染器被禁用,后者只适用,它是不是在你的应用程序。从技术上讲,你可以调用 SetWindowTheme()禁用视觉样式呈现这样MCM_SETCOLOR将重新工作。但是,原来时光倒流到2000年,它看起来相当dinosauric。

From there you can send the MCM messages to configure the calendar. As you can tell, very slim pickings as far as styling goes. You have MCM_SETCALENDARBORDER to change the border thickness and MCM_SETCOLOR to alter colors. The latter only works if the visual style renderer is disabled, it is not in your app. Technically you can call SetWindowTheme() to disable the visual style renderer so MCM_SETCOLOR will work again. But that turns the clock back to the year 2000, it will look quite dinosauric.

这一切,还不足以永远让任何人满意。考虑嵌入WPF的DatePicker克服的造型更多的控制权。

That's all, not enough to ever make anybody happy. Consider embedding a WPF DatePicker to get more control over styling.

这篇关于如何自定义日历中DateTimePicker控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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