增加的DateTimePicker历的字体大小在Win7的Aero主题 [英] Increase Font Size of DateTimePicker Calender in Win7 Aero Theme

查看:1168
本文介绍了增加的DateTimePicker历的字体大小在Win7的Aero主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想改变日历控件的字体大小在Win7使其触摸屏兼容。在我的机器的主题是航空。 CalendarFont 属性没有对Aero主题有任何影响。

所以我overrided OnDropDown方法来禁用主题为压延机的控制。现在的字体已经改变,但压延窗口大小不改变。下图显示了我在看窗外

在code如下。我应该怎么做,以增加日历窗口的大小?

 保护覆盖无效OnDropDown(EventArgs的发送)
    {

        IntPtr的pointerToCalenderWindow = SendMessage函数(手柄,DtmGetmonthcal,0,0);
        // Disble主题
        SetWindowTheme(pointerToCalenderWindow,,);

        VAR RECT =新的Rectangle();
        SendMessage函数(pointerToCalenderWindow,McmGetminreqrect,0,参考RECT);

        的MoveWindow(pointerToCalenderWindow,0,0,rect.Right + 2,rect.Bottom + 2,真正的);

        base.OnDropDown(E);
    }


私人const int的McmFirst = 0×1000;
    私人const int的McmGetminreqrect =(McmFirst + 9);
    私人const int的McsWeeknumbers =为0x4;
    私人const int的DtmFirst = 0×1000;
    私人const int的DtmGetmonthcal =(DtmFirst + 8);

    私人const int的WMPAINT = 0x000F;


    [的DllImport(的uxtheme.dll)]
    私人静态外部INT SetWindowTheme(IntPtr的的HWND,字符串应用程序的名字,串IDLIST);


    [的DllImport(User32.dll中)]
    私人静态外部的IntPtr SendMessage函数(IntPtr的H,
                                             INT味精,
                                             INT参数,
                                             int数据);

    [的DllImport(User32.dll中)]
    私人静态外部INT的MoveWindow(IntPtr的H,
                                         INT X,
                                         INT Y,
                                         INT宽度,
                                         INT高度,
                                         布尔重绘);
 

解决方案

看来,<一个href="http://stackoverflow.com/questions/14559074/setting-calendar-size-when-overriding-datetimepicker-to-add-week-numbers">this问题是差不多的问题,因为你的:

答案指出,有实际使用的日历部件(一个内部和外部的)两个窗口,你需要正确设置大小的外窗。

I want to change the font size of calender control in Win7 to make it touch screen compatible. The theme in my machine is Aero. CalendarFont property does not have any effect on the Aero theme.

So I have overrided OnDropDown method to disable theme for the calander control. Now the font has changed, but the calender window size is not changed. The following image shows the window I am seeing

The code is given below. What should I do to increase the size of the calender window?

 protected override void OnDropDown(EventArgs e)
    {

        IntPtr pointerToCalenderWindow = SendMessage(Handle, DtmGetmonthcal,0,0);
        // Disble Theme
        SetWindowTheme(pointerToCalenderWindow, "", "");      

        var rect = new Rectangle();
        SendMessage(pointerToCalenderWindow, McmGetminreqrect, 0, ref rect);     

        MoveWindow(pointerToCalenderWindow,0,0,rect.Right + 2, rect.Bottom + 2, true);

        base.OnDropDown(e);
    }


private const int McmFirst = 0x1000;
    private const int McmGetminreqrect = (McmFirst + 9);
    private const int McsWeeknumbers = 0x4;
    private const int DtmFirst = 0x1000;
    private const int DtmGetmonthcal = (DtmFirst + 8);

    private const int WMPAINT = 0x000F;


    [DllImport("uxtheme.dll")]
    private static extern int SetWindowTheme(IntPtr hWnd, string appname, string idlist);


    [DllImport("User32.dll")]
    private static extern IntPtr SendMessage(IntPtr h,
                                             int msg,
                                             int param,
                                             int data);

    [DllImport("User32.dll")]
    private static extern int MoveWindow(IntPtr h,
                                         int x,
                                         int y,
                                         int width,
                                         int height,
                                         bool repaint);

解决方案

It seems that this question is about the same problem as yours:

The answer states that there are actually two windows used for the calendar part (an 'inner' and an 'outer' one) and that you need to set the size for the outer window correctly.

这篇关于增加的DateTimePicker历的字体大小在Win7的Aero主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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