Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
715 views
in Technique[技术] by (71.8m points)

c# - Increase Font Size of DateTimePicker Calender in Win7 Aero Theme

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

        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);
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...