WinFontDlg() Function - Sample Code
void SetFont(HWND hOwner, HPS hpsScreen, USHORT usCodePage)
{
extern PFNWP WinFontDlg(); /* Function prototype */
extern FONTDLG fntd; /* Dialog control struct */
static BOOL fFirstTime = TRUE; /* Flag */
CHARBUNDLE cbnd; /* Attributes */
if (FirstTime) /* If invoked for 1st time */
{ /* build control structure */
fntd.cbSize = sizeof(FONTDLG); /* Set size of structure */
fntd.fl = FNTS_CENTER | /* Specify centered dlg */
FNTS_HELPBUTTON; /* Include help button */
fntd.hpsPrinter = NULL; /* No printer font */
fntd.pszTitle = "Fonts"; /* Dialog title text */
fntd.pfnDlgProc = NULL; /* Use standard dlg proc */
fntd.hmod = NULL; /* " " " " */
fntd.idDlg = 0; /* " " " " */
fntd.pszPreview = NULL /* Default preview string */
fntd.pszPtSizeList = NULL; /* Default point sizes */
fntd.flFlags = 0L; /* Default flags */
fntd.szFamilyname[] = '\0'; /* System default */
fntd.fxPointSize = MAKEFIXED(12,0); /* 12-point vertical size */
fntd.usWeight = FWEIGHT_NORMAL; /* Weight or thickness */
fntd.usWidth = FWIDTH_NORMAL; /* Character width */
fntd.flType = 0L; /* No additional attribs */
fntd.flStyle = 0L; /* No additional styles */
fntd.flCHSOptions = 0L; /* No additional options */
fntd.clrFore = CLR_BLACK; /* Black characters */
fntd.clrBack = CLR_WHITE; /* White background */
fntd.fAttrs.usCodePage = usCodePage; /* Specified code page */
fFirstTime=FALSE; /* Reset flag */
}
fntd.hpsScreen=hpsScreen; /* Set presentation space */
WinFontDlg(hOwner, /* Invoke font dialog */
&fntd); /* Control structure ptr */
GpiCreateLogFront(hpsScreen, /* Create logical font */
"Name ", /* Name of font */
0, /* Local font identifier */
fntd.fAttrs); /* Returned attributes */
cbnd.lColor = fntd.clrFore; /* Set foreground color */
cbnd.lBackColor = fntd.clrBack; /* Set background color */
GpiSetAttrs(hpsScreen, /* Set attributes */
PRIM_CHAR, /* Character attributes */
CBB_COLOR | CBB_BACK_COLOR, /* Attributes to be set */
0L, /* Defaults mask */
(PBUNDLE)&cbnd); /* Attribute structure */
GpiCharStringPos(hpsScreen, /* Write character string */
NULL, /* No rectangle */
fntd.flCHSOptions, /* Options */
4, /* Number of bytes */
"Text", /* Text string */
NULL); /* Increment values */
}
[Back: Standard Dialogs - WinFileDlg() Function]
[Next: DosCreateThread() Function]