c# 请问如何设置combobox里某个下拉项的字体粗细
1.生成一个新类CMyComboBox,继承CComboBox
2.重载WM_CREATE,并增加变量 CFont m_font;
3.在OnCreate()里加如下代码:
//设置字体
LOGFONT logFont;
CClientDC dc(this);
::EnumFontFamilies(dc.m_hDC, _T("新细明体"),
FontEnumProc, (LPARAM)&logFont);
// change the weight and create the font
int PointSize = 12;
logFont.lfWeight = FW_NORMAL;
logFont.lfHeight = -MulDiv(PointSize, GetDeviceCaps(dc, LOGPIXELSY), 72);
logFont.lfWidth = 0;
if (m_font.CreateFontIndirect(&logFont))
SetFont(&m_font);
4.函数FontEnumProc()全局性的静态函数
static int CALLBACK FontEnumProc(const LOGFONT *pLogFont,
const TEXTMETRIC *pTextMetric,
DWORD type, LPARAM pDestLogFont)
{
memcpy((BYTE*)pDestLogFont, pLogFont, sizeof(LOGFONT));
return FALSE; // return the first font in the family(i.e. smallest).
}
5.其馀的控件也可如法炮制
或者: