This example displays a font selection dialog by using WinFontDlg, which allows the user to select a font.
#define INCL_WINSTDFONT /* Window Standard Font Functions */ #include <os2.h> #include <string.h> HPS hpsScreen; /* Screen presentation space */ FONTDLG pfdFontdlg; /* Font dialog info structure */ HWND hwndMain; /* Window that owns the font dialog */ HWND hwndFontDlg; /* Font dialog window */ char szFamilyname[FACESIZE]; /***************************************************************/ /* Initially set all fields to 0. */ /***************************************************************/ memset(&pfdFontdlg,0,sizeof(FONTDLG)); /***************************************************************/ /* Get handle to presentation space. */ /***************************************************************/ hpsScreen=WinGetPS(hwndMain); /***************************************************************/ /* Initialize those fields in the FONTDLG structure that are */ /* used by the application */ /***************************************************************/ pfdFontdlg.cbSize=sizeof(FONTDLG); /* Size of structure */ pfdFontdlg.hpsScreen=hpsScreen; /* Screen presentation */ /* space */ szFamilyname[0]='\0'; /* Use default font */ pfdFontdlg.pszFamilyname=szFamilyname; /* Provide buffer */ pfdFontdlg.usFamilyBufLen = sizeof(szFamilyname); /* Font family name */ pfdFontdlg.fxPointSize=MAKEFIXED(10,0);/* Font point size */ pfdFontdlg.fl=FNTS_HELPBUTTON | FNTS_CENTER; /* FNTS_* flags */ pfdFontdlg.clrFore=CLR_BLACK; /* Foreground color */ pfdFontdlg.clrBack=CLR_WHITE; /* Background color */ pfdFontdlg.fAttrs.usCodePage=437; /* Code page to select */ /* from */ /***************************************************************/ /* Display the font dialog and get the font */ /***************************************************************/ hwndFontDlg=WinFontDlg(HWND_DESKTOP,hwndMain,&pfdFontdlg); if(hwndFontDlg &&(pfdFontdlg.lReturn==DID_OK)) { /************************************************************/ /* Upon successful return of a font, the application can */ /* use font information selected by the user to create a */ /* font, load a font, and so forth */ /************************************************************/ } WinReleasePS(hpsScreen);