示例:
// The following code example creates a font
// (Arial, 10 pixels high) and if successful,
// stores the result in m_pMonthFont. SetMonthCalFont
// is then called passing in the new font, causing
// the month calendar control to display all
// text and dates with an Arial font.
if (m_pMonthFont->CreateFontIndirect(&lf))
{
// if successful, grab the month calendar control from
// our dialog and set the font
CMonthCalCtrl* pCtrl = (CMonthCalCtrl*) GetDlgItem(IDC_DATETIME1);
ASSERT(pCtrl != NULL);
pCtrl->SetMonthCalFont(m_pMonthFont);
}
else
{
// if not successful, clean up the font pointer and
// set equal to NULL
delete m_pMonthFont;
m_pMonthFont = NULL;
}
// ... other code here ...
}
CYourDialog::CYourDialog(CWnd* pParent /*=NULL*/) : CDialog(CYourDialog::IDD, pParent)
{
// ... other code here ...
m_pMonthFont = NULL;
// ... other code here ...
}
CYourDialog::~CYourDialog()
{
// ... other code here ...
delete m_pMonthFont;
// ... other code here ...
}