Creación de una fuente lógica

Puede usar el cuadro de diálogo Común fuente para mostrar las fuentes disponibles. El cuadro de diálogo ChooseFont se muestra después de que una aplicación inicialice los miembros de una estructura CHOOSEFONT y llame a la función CHOOSEFONT . Después de que el usuario seleccione una de las fuentes disponibles y presione el botón Aceptar , la función ChooseFont inicializa una estructura LOGFONT con los datos pertinentes. A continuación, la aplicación puede llamar a la función CreateFontIndirect y crear una fuente lógica basada en la solicitud del usuario. En el ejemplo siguiente se muestra cómo se hace esto.

HFONT FAR PASCAL MyCreateFont( void ) 
{ 
    CHOOSEFONT cf; 
    LOGFONT lf; 
    HFONT hfont; 
 
    // Initialize members of the CHOOSEFONT structure.  
 
    cf.lStructSize = sizeof(CHOOSEFONT); 
    cf.hwndOwner = (HWND)NULL; 
    cf.hDC = (HDC)NULL; 
    cf.lpLogFont = &lf; 
    cf.iPointSize = 0; 
    cf.Flags = CF_SCREENFONTS; 
    cf.rgbColors = RGB(0,0,0); 
    cf.lCustData = 0L; 
    cf.lpfnHook = (LPCFHOOKPROC)NULL; 
    cf.lpTemplateName = (LPSTR)NULL; 
    cf.hInstance = (HINSTANCE) NULL; 
    cf.lpszStyle = (LPSTR)NULL; 
    cf.nFontType = SCREEN_FONTTYPE; 
    cf.nSizeMin = 0; 
    cf.nSizeMax = 0; 
 
    // Display the CHOOSEFONT common-dialog box.  
 
    ChooseFont(&cf); 
 
    // Create a logical font based on the user's  
    // selection and return a handle identifying  
    // that font.  
 
    hfont = CreateFontIndirect(cf.lpLogFont); 
    return (hfont); 
}