显示一个派生类的DateTimePicker自定义日历下拉 [英] Show a custom calendar dropdown with a derived DateTimePicker class

查看:555
本文介绍了显示一个派生类的DateTimePicker自定义日历下拉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是在.NET 2.0,它显示了一个自定义日历下拉列表,而不是Windows的默认日历弹出创建一个自定义的DateTimePicker类。



通过观察Windows消息(见附表代码),我能够找到并隐藏/创建后关闭日历窗口



然而,问题依然存在:日历窗口关闭后,东西仍阻止鼠标输入。例如,如果你试图最大限度的定制DateTimePicker控件的所有者形式日历下拉已关闭编程(附代码)后,最大化按钮没有反应。只剩下一点击的作品。有趣的是,非功能点击触发DTN_CLOSEUP通知,所以现在看来​​,WM_CLOSE没有正确关闭日历。



这是如何完成我的任务任何提示高度赞赏:)

 保护覆盖无效的WndProc(参考System.Windows.Forms.Message米)
$ { b $ b如果(m.Msg ==(INT)SYSMSG.WM_REFLECT +(INT)SYSMSG.WM_NOTIFY)
{
NMHDR NMHDR =(NMHDR)m.GetLParam(typeof运算(NMHDR));
开关(nmhdr.code)
{
情况下DTN_DROPDOWN:
//隐藏窗口
IntPtr的calHandle = FindWindow函数(SysMonthCal32,NULL);
的SendMessage(calHandle,(INT)SYSMSG.WM_SIZE,0,SP.Convert.MakeLong(0,0));

this.BeginInvoke((MethodInvoker)委托()
{
的SendMessage(calHandle,(INT)SYSMSG.WM_CLOSE,0,0);
});
中断;
}

}

base.WndProc(REF米);
}


解决方案

我终于找到了这完全可定制日期选择器(MONTHCALENDAR渲染否决能):文化感知月历和日期选择在CodeProject


My goal is to create a custom DateTimePicker class in .NET 2.0, which shows a custom calendar dropdown instead of the Windows default calendar popup.

By observing Windows messages (see attached code), I am able to find and hide/close the calendar window after creation.

However, a problem remains: After the calendar window is closed, something is still blocking the mouse input. For example, if you try to maximise the owner form of the customised DateTimePicker control after the calendar dropdown has been closed programmatically (attached code), the maximise button does not respond. Only the next click works. Interestingly, the "non-functional click" fires the DTN_CLOSEUP notification, so it appears that the WM_CLOSE did not properly close the calendar.

Any hints on how to accomplish my task are highly appreciated :)

protected override void WndProc(ref System.Windows.Forms.Message m)
{
    if (m.Msg == (int)SYSMSG.WM_REFLECT + (int)SYSMSG.WM_NOTIFY)
    {
        NMHDR nmhdr = (NMHDR)m.GetLParam(typeof(NMHDR));
        switch (nmhdr.code)
        {
            case DTN_DROPDOWN:
                // Hide window
                IntPtr calHandle = FindWindow("SysMonthCal32", null);
                SendMessage(calHandle, (int)SYSMSG.WM_SIZE, 0, SP.Convert.MakeLong(0, 0));

                this.BeginInvoke((MethodInvoker)delegate()
                {
                    SendMessage(calHandle, (int)SYSMSG.WM_CLOSE, 0, 0);
                });
                break;
        }

    }

    base.WndProc(ref m);
}

解决方案

I finally found this fully customisable datePicker (monthCalendar rendering is override-able) : Culture Aware Month Calendar and Datepicker on CodeProject

这篇关于显示一个派生类的DateTimePicker自定义日历下拉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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