CDateTimeCtrl::SetMonthCalFont
设置日期和时间选择器控件的子month calendar控件将使用的字体。
void SetMonthCalFont(
HFONT hFont,
BOOL bRedraw = TRUE
);
参数
hFont
要设置的字体的句柄。bRedraw
指定是否应重新绘制该控件会立即在设置字体。 设置为 TRUE 的此参数导致控件重绘自身。
备注
此成员函数实现Win32消息 DTM_SETMCFONT的行为,如 Windows SDK所述。
示例
// The following code example would most likely appear
// in the OnInitDialog function of your dialog class.
// It creates a font (Arial, 10 pixels high) and if successful,
// stores the result in m_MonthFont, a member of your
// dialog class declared as follows:
// CFont m_MonthFont;
// SetMonthCalFont is then called passing in the new font,
// causing the month calendar control to display all
// text and dates with an Arial font.
//initializing the necessary members of the LOGFONT
// structure
LOGFONT lf;
memset(&lf, 0, sizeof(lf));
lf.lfHeight = 10;
_tcscpy_s(lf.lfFaceName, LF_FACESIZE, _T("Arial"));
if (m_MonthFont.CreateFontIndirect(&lf))
{
// if successful, set the month calendar font
m_DateTimeCtrl.SetMonthCalFont((HFONT)m_MonthFont);
}
备注
如果使用此代码,将若要使成员您的 CDialog派生类调用的 m_MonthFont 类型 CFont。
要求
Header: afxdtctl.h