VC 获取已系统安装的字体
转载请注明来源:https://www.cnblogs.com/hookjc/
BOOL CALLBACK EnumFonts(CONST LOGFONT* lplf, CONST TEXTMETRIC *lptm,DWORD dwType,LPARAM lparam)
{
CString tempFontName(lplf->lfFaceName);
CString temp=gSysFontNames;
if(tempFontName.Find("@")!=-1)
return true;
//可对tempFontName自行附加过滤条件
//{
gSysFontNames.Format("%s,%s",temp,tempFontName);
//}
return true;
}
void CDialogTest:OnButton1()
{
AfxMessageBox(GetSystemFontName((LPVOID)this);
}
CString CDialogTest::GetSysFontName(LPVOID lp)
{
gSysFontNames="";
try
{
CPaintDC dc((CWnd*)lp);
::EnumFonts(dc.m_hDC,NULL,(FONTENUMPROC)EnumFonts,0);
return gSysFontNames.Mid(1);
}
catch(...)
{
return "";
}
}