CFont * f;
f = new CFont;
f->CreateFont(24, // nHeight
0, // nWidth
0, // nEscapement
1, // nOrientation
FW_BOLD, // nWeight
TRUE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
_T("Arial")); // lpszFac
GetDlgItem(IDC_STATIC_SYSSET)->SetFont(f); 用上面方法更改字体,字号,但是字体只能为 _T("Arial"));我在里面添加"宋体"确仍然显示"Arial"没有变化,请高手指点,或是给兄弟指一条其他更改字体,字号的方法.谢谢!
f = new CFont;
f->CreateFont(24, // nHeight
0, // nWidth
0, // nEscapement
1, // nOrientation
FW_BOLD, // nWeight
TRUE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
_T("Arial")); // lpszFac
GetDlgItem(IDC_STATIC_SYSSET)->SetFont(f); 用上面方法更改字体,字号,但是字体只能为 _T("Arial"));我在里面添加"宋体"确仍然显示"Arial"没有变化,请高手指点,或是给兄弟指一条其他更改字体,字号的方法.谢谢!
设成系统当前的字体,这时
GetDlgItem(IDC_STATIC_SYSSET)->SetFont(f);才会得到“宋体”
没有取得dc指针,我用语句CPaintDC dc(this);获取指针后还是出问题!!!
BOOL CSysDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CFont * f;
f = new CFont;
f->CreateFont(24, // nHeight
0, // nWidth
0, // nEscapement
1, // nOrientation
FW_BOLD, // nWeight
TRUE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
_T("Arial")); // lpszFac
GetDlgItem(IDC_STATIC_SYSSET)->SetFont(f);……
}
请给出完整一些的代码!谢谢!
BOOL CAbcDlg::OnInitDialog()
{
CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
} // Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
CFont font;
VERIFY(font.CreateFont(
18, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
"宋体")); // lpszFacename GetDlgItem(IDC_EDIT1)->SetFont(&font);
return TRUE; // return TRUE unless you set the focus to a control
}
OK
我设的对话框的字体是“仿宋....”用这个就在IDC_EDIT1输出宋体