我需要在 mfc 的 CButton 上显示符号字体。如何做到这一点?代码示例更有帮助。符号字体可以来自 webdings 或 cusotm 安装的字体。
我尝试了下面提到的代码,但它不起作用。我把这段代码放在对话框的 onpaint 方法中。
CWnd *win = GetDlgItem(IDC_BUTTON1);
CDC *dc = win->GetDC();
CFont font;
VERIFY(font.CreateFont(
12, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
SYMBOL_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
_T("SAPDings"))); // lpszFacename
// Do something with the font just created...
//CClientDC dc(this);
CFont* def_font = dc->SelectObject(&font);
dc->TextOutW(5, 5, _T("0x0027"), 5);
dc->SelectObject(def_font);
// Done with the font. Delete the font object.
font.DeleteObject();