• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

GDI: EnumFontFamilies Function

Started by José Roca, August 22, 2011, 01:47:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca

 
The following code displays the font names and styles.


' ########################################################################################
' The following code displays the font names and styles.
' ########################################################################################

' CSED_PBCC - Use the PBCC compiler
#COMPILE EXE
#DIM ALL
#INCLUDE "windows.inc"

' ========================================================================================
' Main
' ========================================================================================
FUNCTION PBMAIN () AS LONG

   LOCAL hdc AS DWORD

   ' Create a device context
   hdc = GetDC(%HWND_DESKTOP)
   ' Enumerate the fonts
   EnumFontFamilies hDc, BYVAL %NULL, CODEPTR(EnumFontFamProc), BYVAL %NULL
   ' Delete the device context
   DeleteDC hdc

   WAITKEY$

END FUNCTION
' ========================================================================================

' ========================================================================================
' EnumFontFamProc callback procedure
' ========================================================================================
FUNCTION EnumFontFamProc (BYREF lpelf AS ENUMLOGFONT, BYREF lpntm AS NEWTEXTMETRIC, BYVAL FontType AS DWORD, BYVAL lParam AS DWORD) AS LONG

   PRINT "Font name: " lpelf.elfFullName " ";
   PRINT "Font style: " lpelf.elfStyle
   FUNCTION = %TRUE

END FUNCTION
' ========================================================================================