L_DlgSetFont

#include "l_bitmap.h"

HFONT EXT_FUNCTION L_DlgSetFont(hFont)

HFONT hFont;

/* handle to the selected font */

Sets the font for the LEADTOOLS Common Dialogs.

Parameter

Description

hFont

Handle to the selected font.

Returns

!NULL

The previous font.

NULL

An error occurred.

Comments

The default font is your system’s default font.

Call this function with hFont set to NULL to use the default system font.

The hFont parameter will not be copied. You must insure that the hFont remains valid until it is no longer needed.

Required DLLs and Libraries

LTDLGKRN
LTKRN

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

See Also

Functions:

L_DlgGetString, L_DlgSetString, L_DlgSetFont

Topics:

Dialogs: Maintenance and General Use

 

Using Imaging Common Dialog

Example

L_VOID L_EXPORT DlgHelpCB ( L_UINT32 uFlag, L_INT nCtlID )
{
   switch ( uFlag )
   {
      case DLG_HELP_SOLARIZE:
      {
         switch (nCtlID )
         {
            case LT_DLG_SOLARIZE_IDDLG:
            case LT_DLG_SOLARIZE_IDEDT_THRESHOLD:
            {
               MessageBox (NULL, TEXT("Help with Solarize!"), TEXT("Help"), MB_OK);

               break ;
            }
         }

         break ;
      }
   }
}

L_VOID ShowDialog ( HWND hWnd, pBITMAPHANDLE pBitmap )
{
   HDC hDC;
   L_UINT uLen;
   HFONT hMyFont = NULL;
   L_TCHAR L_FAR* pszString = NULL;
   L_TCHAR szNewCaption [] = TEXT("My New Solarize Caption");

   hDC = GetDC (NULL);

   // set a custom font and string for the emboss dialog
   // NOTE, you should change the font name to a font on your system
   hMyFont = CreateFont ( - MulDiv (8, GetDeviceCaps(hDC, LOGPIXELSY), 72),
                          0,
                          0,
                          0,
                          FW_BOLD, 
                          FALSE, 
                          FALSE, 
                          FALSE,
                          DEFAULT_CHARSET, 
                          OUT_DEFAULT_PRECIS, 
                          CLIP_DEFAULT_PRECIS,
                          DEFAULT_QUALITY, 
                          DEFAULT_PITCH,
                          TEXT("Bones"));

   L_DlgInit (0);

   L_DlgSetFont (hMyFont);

   // Get the default caption string
   L_DlgGetStringLen ( DLG_SOLARIZE_IDSTR_CAPTION, &uLen ) ;

   // sdd 1, for the terminating NULL
   pszString = ( L_TCHAR L_FAR* ) GlobalAlloc ( GMEM_FIXED, ( uLen * sizeof ( L_TCHAR ) + 1 ) ) ; 

   L_DlgGetString ( DLG_SOLARIZE_IDSTR_CAPTION, pszString ) ;

   // display default caption string
   MessageBox ( hWnd, pszString, TEXT("Default"), MB_OK ) ;

   GlobalFree ( pszString ) ;

   // change caption string
   L_DlgSetString ( DLG_SOLARIZE_IDSTR_CAPTION, szNewCaption ) ;

   // now, display the dialog to see our changes
   {
      SOLARIZEDLGPARAMS DlgParams ; 

      memset ( &DlgParams, 0, sizeof ( SOLARIZEDLGPARAMS ) ) ;

      DlgParams.uStructSize           = sizeof ( SOLARIZEDLGPARAMS ) ;
      DlgParams.pBitmap         = pBitmap ;
      DlgParams.pfnHelpCallback = ( LTCOMMDLGHELPCB ) DlgHelpCB ;
      DlgParams.uDlgFlags       = DLG_SOLARIZE_AUTOPROCESS      |
                                  DLG_SOLARIZE_SHOW_CONTEXTHELP |
                                  DLG_SOLARIZE_SHOW_PREVIEW     | 
                                  DLG_SOLARIZE_SHOW_TOOL_ZOOMLEVEL ;

      L_DlgSolarize ( hWnd, &DlgParams ) ;
   }

   L_DlgSetFont ( NULL ) ;
   L_DlgFree( ) ;
   DeleteObject ( hMyFont ) ;
   ReleaseDC ( NULL, hDC ) ;
}