字体选择:
void CSearchDlg::OnChoiceFont()
{
// TODO: Add your control notification handler code here
CFontDialog font;
if(font.m_cf.hDC!=NULL)
{
font.m_cf.Flags= CF_INITTOLOGFONTSTRUCT;
font.m_cf.lpLogFont=& m_cho_font;
}
if(font.DoModal()==IDOK)
{
if(m_font.m_hObject!=NULL)
m_font.DeleteObject();
m_font.CreateFontIndirect(font.m_cf.lpLogFont);
//Invalidate();
}
}
选字体:HBRUSH CSearchDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
CFont font,*old_font;
// TODO: Change any attributes of the DC here
switch(pWnd->GetDlgCtrlID( ))
{
case IDC_CITY:
case IDC_AREA_CODE:
case IDC_ZIP_CODE:
{
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(m_cho_color);
if(m_font.m_hObject)
pDC->SelectObject(&m_font);
}
} // TODO: Return a different brush if the default is not desired
return hbr;
}
字体总是倒立的;;
void CSearchDlg::OnChoiceFont()
{
// TODO: Add your control notification handler code here
CFontDialog font;
if(font.m_cf.hDC!=NULL)
{
font.m_cf.Flags= CF_INITTOLOGFONTSTRUCT;
font.m_cf.lpLogFont=& m_cho_font;
}
if(font.DoModal()==IDOK)
{
if(m_font.m_hObject!=NULL)
m_font.DeleteObject();
m_font.CreateFontIndirect(font.m_cf.lpLogFont);
//Invalidate();
}
}
选字体:HBRUSH CSearchDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
CFont font,*old_font;
// TODO: Change any attributes of the DC here
switch(pWnd->GetDlgCtrlID( ))
{
case IDC_CITY:
case IDC_AREA_CODE:
case IDC_ZIP_CODE:
{
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(m_cho_color);
if(m_font.m_hObject)
pDC->SelectObject(&m_font);
}
} // TODO: Return a different brush if the default is not desired
return hbr;
}
字体总是倒立的;;
if(Dlg.DoModal()==IDOK)
{
CString strFace=Dlg.GetFaceName();
int size=Dlg.GetSize();
CFont font;
font.CreatePointFont(size,strFace);
GetDlgItem(IDC_EDIT)->SetFont(font);
UpdateData(false);
}