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);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…