codice:
void MioDlg::OnFont()
{
CFont font;
CFont* pFont = GetFont();
LOGFONT lf;
pFont = Win->GetFont();
if (pFont)
{
pFont->GetLogFont(&lf);
CFontDialog dlg(&lf);
if (dlg.DoModal() == IDOK)
{
LOGFONT lf;
memcpy(&lf, dlg.m_cf.lpLogFont, sizeof(LOGFONT));
font.CreateFontIndirect(&lf);
Win->SetFont(&font, TRUE);
}
}
else
{
MessageBox("This Window/Control dosen't support Font changing.", "Error!", MB_OK | MB_ICONERROR);
}
}
Dove "Win" è il controllo preso dal WindowFromPoint, ad esempio un pulsante.