EnumFontFamiliesEx only returns one font -- SOLVED
-
Hi all, I'm trying to use EnumFontFamiliesEx to get all the fonts on a Windows 7 system, and it only returns one font: "System". I tried to follow the incomplete documentation for this function here: http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k%28%22WINGDI%2fENUMFONTFAMILIESEX%22%29;k%28ENUMFONTFAMILIESEX%29;k%28DevLang-%22C%2B%2B%22%29;k%28TargetOS-WINDOWS%29&rd=true[^] but with no luck. Here's my function (in a dialog-based MFC app):
void CAllFontsDlg::fillListBoxWithFonts ()
{
lb = (CListBox*) GetDlgItem (IDC_LIST1);
CDC* pDC = GetDC ();
LOGFONT lf;// To enumerate all styles and charsets of all fonts: lf.lfFaceName\[0\] = '\\0'; lf.lfCharSet = DEFAULT\_CHARSET; HRESULT hr; hr = EnumFontFamiliesEx (pDC->m\_hDC, &lf, EnumFontFamExProc, 0, 0);
}
And here's my callback function (which is called exactly once):
CListBox* lb;
int CALLBACK EnumFontFamExProc(
const LOGFONT *lpelfe,
const TEXTMETRIC *lpntme,
DWORD FontType,
LPARAM lParam)
{lb->AddString (lpelfe->lfFaceName); return 0;
}
Can anyone see what I'm doing wrong? Thanks!
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
-
Hi all, I'm trying to use EnumFontFamiliesEx to get all the fonts on a Windows 7 system, and it only returns one font: "System". I tried to follow the incomplete documentation for this function here: http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k%28%22WINGDI%2fENUMFONTFAMILIESEX%22%29;k%28ENUMFONTFAMILIESEX%29;k%28DevLang-%22C%2B%2B%22%29;k%28TargetOS-WINDOWS%29&rd=true[^] but with no luck. Here's my function (in a dialog-based MFC app):
void CAllFontsDlg::fillListBoxWithFonts ()
{
lb = (CListBox*) GetDlgItem (IDC_LIST1);
CDC* pDC = GetDC ();
LOGFONT lf;// To enumerate all styles and charsets of all fonts: lf.lfFaceName\[0\] = '\\0'; lf.lfCharSet = DEFAULT\_CHARSET; HRESULT hr; hr = EnumFontFamiliesEx (pDC->m\_hDC, &lf, EnumFontFamExProc, 0, 0);
}
And here's my callback function (which is called exactly once):
CListBox* lb;
int CALLBACK EnumFontFamExProc(
const LOGFONT *lpelfe,
const TEXTMETRIC *lpntme,
DWORD FontType,
LPARAM lParam)
{lb->AddString (lpelfe->lfFaceName); return 0;
}
Can anyone see what I'm doing wrong? Thanks!
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
Solved my own problem! The "return 0" in the callback function was terminating the enumeration the first time through! My fault...
"Microsoft -- Adding unnecessary complexity to your work since 1987!"