Question : Use of EnumFontFamilies

I need to use the EnumFontFamilies function to retrieve a listing off all of a user's installed fonts.  However, I can't for the life of me figure out how to use EnumFontFamilies.  I'd really appreciate an explanation of what each parameter in EnumFontFamilies work, and a some sample source code.  Relatively urgent.  TIA.

Answer : Use of EnumFontFamilies

The following code reads the available fonts into a CArray:

int CALLBACK EnumTheFonts(
                               LOGFONT *lpLF, TEXTMETRIC *lpTM, DWORD dwTyp, LPARAM lpData)
{
  CArray *paFonts=(CArrayString&>*)lpData;
  paFonts->Add(CString(lpLF->lfFaceName));
  return 1;
}

void GetFonts(CArraytring&>* aFonts)
{
// Get a temporary DC(for EnumFonts)
  HWND hDskWnd=::GetDesktopWindow();
  HDC     htempDC=::GetDC(hDskWnd);
  HDC     hMyDC=::CreateCompatibleDC(htempDC);
  ::ReleaseDC(hDskWnd,htempDC);
 
  ::EnumFonts(hMyDC,NULL,(FONTENUMPROC)EnumTheFonts,(LPARAM)aFonts);

  ::DeleteDC(hMyDC);
}

Just create a CArray and pass a pointer to that array to the
GetFonts() function. After that, the array is filled with the available fonts.
Hope this is what you needed :)

Random Solutions  
 
programming4us programming4us