需求: 一个activex控件,有一自定义的font属性,默认是TTAD字体。
如果系统中没有安装这种字体,则使用MS gosic。怎样判断TTAD字体在系统中是否已安装呢?如果不判断,当TTAD没有时,
系统会按字母顺序使用已安装的第一个字体。我使用了下面方法判断:LOGFONT lp;
wcscpy(lp.lfFaceName, _T("TTADゴシック"));FONTENUMPROC lpEnumFontFamExProc = (FONTENUMPROC)EnumFontFamProc;
HDC hdc = ::GetDC((HWND)this->GetHwnd());
int ret;
ret = EnumFontFamiliesEx(hdc, &lp, (FONTENUMPROC)EnumFontFamExProc, (LPARAM)this, 0);int CALLBACK EnumFontFamExProc(ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX *lpntme, DWORD FontType, LPARAM lParam)
{
//you may add the font names to a listbox
//list1.AddString(lpelf->elfLogFont.lfFaceName);
//PX_Font(pPX, _T("FunKeyFont"), m_fontFunKey, &_fontdescHeading);
bExits = TRUE;
return 0;
}
但发现根本不能进入回调函数。谁有比较好的简便的方法?多谢了!
如果系统中没有安装这种字体,则使用MS gosic。怎样判断TTAD字体在系统中是否已安装呢?如果不判断,当TTAD没有时,
系统会按字母顺序使用已安装的第一个字体。我使用了下面方法判断:LOGFONT lp;
wcscpy(lp.lfFaceName, _T("TTADゴシック"));FONTENUMPROC lpEnumFontFamExProc = (FONTENUMPROC)EnumFontFamProc;
HDC hdc = ::GetDC((HWND)this->GetHwnd());
int ret;
ret = EnumFontFamiliesEx(hdc, &lp, (FONTENUMPROC)EnumFontFamExProc, (LPARAM)this, 0);int CALLBACK EnumFontFamExProc(ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX *lpntme, DWORD FontType, LPARAM lParam)
{
//you may add the font names to a listbox
//list1.AddString(lpelf->elfLogFont.lfFaceName);
//PX_Font(pPX, _T("FunKeyFont"), m_fontFunKey, &_fontdescHeading);
bExits = TRUE;
return 0;
}
但发现根本不能进入回调函数。谁有比较好的简便的方法?多谢了!
{
LOGFONT lf;
lf.lfCharSet = DEFAULT_CHARSET; // Initialize the LOGFONT structure
strcpy(lf.lfFaceName,"");
CClientDC dc (this);
// Enumerate the font families
::EnumFontFamiliesEx((HDC) dc,&lf,(FONTENUMPROC) EnumFontFamProc,(LPARAM) this,0);
}
catch(...){}
//*****************************************************************************//枚举函数
int CALLBACK EnumFontFamProc(LPENUMLOGFONT lpelf,LPNEWTEXTMETRIC lpntm,DWORD nFontType,long lparam)
{
CString sa=(CString)lpelf ->elfLogFont.lfFaceName;
if(sa.CompareNoCase("TTAD")==0)
{
//***************
ssff_you=true;
//****************
}
return 1;
}
LOGFONT lf;
lf.lfCharSet = DEFAULT_CHARSET; // Initialize the LOGFONT structure
strcpy(lf.lfFaceName,"TTAD"); 看了msdn上的说明,EnumFontFamProc枚举font是依据charset和typeface这两个项目,
难道是因为TTAD不正确?
结贴了!