Increase Font Size of DateTimePicker Calender in Win7 Aero Theme

Posted on

Problem :

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 seeingenter image description here

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);


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;

    private static extern int SetWindowTheme(IntPtr hWnd, string appname, string idlist);

    private static extern IntPtr SendMessage(IntPtr h,
                                             int msg,
                                             int param,
                                             int data);

    private static extern int MoveWindow(IntPtr h,
                                         int x,
                                         int y,
                                         int width,
                                         int height,
                                         bool repaint);

Solution :

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.

Leave a Reply

Your email address will not be published. Required fields are marked *