VC 快速枚举系统所有字体

转载:http://www.cnblogs.com/mars9/archive/2012/01/13/2321622.html

int EnumFontFamiliesEx(
HDC hdc,                          // handle to DC
LPLOGFONT lpLogfont,              // font information
FONTENUMPROC lpEnumFontFamExProc, // callback function
LPARAM lParam,                    // additional data
DWORD dwFlags                     // not used; must be 0
);

Combobox  m_Combo;

INT CALLBACK NEnumFontNameProc(LOGFONT *plf, TEXTMETRIC* /*ptm*/, INT /*nFontType*/, LPARAM lParam)
{
CComboBox* comboBox = (CComboBox*) lParam;

comboBox->AddString(plf->lfFaceName);

return TRUE;
}

///////////////列举本机所有字体
::EnumFontFamilies(GetDC()->m_hDC, (LPTSTR) NULL, (FONTENUMPROC)NEnumFontNameProc, (LPARAM)&(m_Combo));
int nCount = m_Combo.GetCount();
if (nCount > 0)
m_Combo.SetCurSel(nCount-5);
else
m_Combo.SetCurSel(0);

此条目发表在C++分类目录,贴了标签。将固定链接加入收藏夹。

发表评论