Knowledge Base Nr: 00314 simplefontdlg.cpp - http://www.swe-kaiser.de

MFC: common dialog modifizieren (farbe und vorschau für CFontDialog ausblenden)
ACHTUNG: funktioniert nur für deutsche sprache!!!

  
- neuen dialog von CFontDialog ableiten und OnInitDialog() überladen

BOOL CSimpleFontDialog::OnInitDialog()
{
CFontDialog::OnInitDialog();

CWnd* pWnd = GetWindow(GW_CHILD);

while (pWnd != NULL)
{
CString sTitle;
pWnd->GetWindowText(sTitle);

//ACHTUNG: funktioniert nur für deutsche sprache!!!
if (sTitle == L"Beispiel")
{
CRect rectDialog, rectControl;
int nNewHeight = -1;

GetWindowRect(&rectDialog);
pWnd->GetWindowRect(&rectControl);
nNewHeight = rectControl.top - rectDialog.top;

SetWindowPos(NULL, 0, 0, rectDialog.Width(), nNewHeight, SWP_NOMOVE|SWP_NOZORDER);
break;
}

pWnd = pWnd->GetWindow(GW_HWNDNEXT);
}

return TRUE; // return TRUE unless you set the focus to a control
// AUSNAHME: OCX-Eigenschaftenseite muss FALSE zurückgeben.
}

//beispiel: font vorher auf bestimmte größe festlegen
void CBaseObject::SetFontSize(CBaseView* pView)
{
CClientDC dc(pView);
m_lfFont.lfHeight = -MulDiv(m_nFontSize, dc.GetDeviceCaps(LOGPIXELSY), 72);

CSimpleFontDialog dlg(&m_lfFont, CF_SCREENFONTS|CF_INITTOLOGFONTSTRUCT|CF_NOSCRIPTSEL);
if (dlg.DoModal() == IDOK)
{
...
}

return 0;
}