LDialogBase::SetFont

#include "ltwrappr.h"

static HFONT LDialogBase::SetFont(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 systems 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

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:

LDialogBase::GetString, LDialogBase::SetString, LDialogBase::SetFont, Class Members

Topics:

Using Imaging Common Dialog

Example

class CMyColorDlg : public LDialogColor 
{ 
public:  
   L_VOID DlgHelpCallBack(L_UINT32 uFlag, L_INT nCtlID );  
}; 
 
L_VOID CMyColorDlg::DlgHelpCallBack(L_UINT32 uFlag, L_INT nCtlID )  
{ 
   switch ( uFlag ) 
   { 
   case DLG_HELP_SOLARIZE: 
      { 
         switch (nCtlID ) 
         { 
         case DLG_SOLARIZE_IDSTR_CAPTION:  
         case DLG_SOLARIZE_IDSTR_THRESHOLD:  
            { 
               MessageBox ( NULL,  
                            TEXT("Help with Solarize!"),  
                            TEXT("Help"),  
                            MB_OK ) ;  
 
               break ;  
            } 
         } 
 
         break ;  
      } 
   } 
} 
 
L_INT LDialogBase_SetFontExample(LBitmap * pBitmap, HWND hWnd)  
{ 
   L_INT       nRet; 
   L_UINT      uLen ;  
   HFONT       hMyFont = NULL ;  
   L_TCHAR*    pszString = NULL ;  
   L_TCHAR     szNewCaption [] = TEXT("My New Solarize Caption"); 
   CMyColorDlg ColorDlg; 
 
   ColorDlg.Initialize(0); 
 
   HDC m_pDC = GetDC ( hWnd);  
   hMyFont = CreateFont ( - MulDiv ( 8, GetDeviceCaps ( m_pDC, LOGPIXELSY ), 72 ),  
                          0,  
                          0,  
                          0,  
                          FW_BOLD,  
                          FALSE,  
                          FALSE,  
                          FALSE,  
                          DEFAULT_CHARSET,  
                          OUT_DEFAULT_PRECIS,  
                          CLIP_DEFAULT_PRECIS,  
                          DEFAULT_QUALITY,  
                          DEFAULT_PITCH,  
                          TEXT("Bones")) ;  
   if(ColorDlg.SetFont ( hMyFont ) == NULL) 
      return FAILURE; 
 
   nRet = ColorDlg.GetStringLen ( DLG_SOLARIZE_IDSTR_CAPTION, &uLen ) ;  
   if(nRet != SUCCESS) 
      return nRet; 
 
   // add 1, for the terminating NULL 
   pszString = ( L_TCHAR * ) GlobalAlloc ( GMEM_FIXED,  
                                               ( (uLen+1) * sizeof ( L_TCHAR )) ) ;  
 
   nRet = ColorDlg.GetString( DLG_SOLARIZE_IDSTR_CAPTION, pszString, uLen+1) ;  
   if(nRet != SUCCESS) 
      return nRet; 
 
   // display default caption string 
   MessageBox ( hWnd,pszString, TEXT("Default"), MB_OK ) ;  
 
   GlobalFree ( pszString ) ;  
 
   // change caption string 
   nRet = ColorDlg.SetString ( DLG_SOLARIZE_IDSTR_CAPTION, szNewCaption ) ;  
   if(nRet != SUCCESS) 
      return nRet; 
 
   // now, display the dialog to see our changes 
   { 
      SOLARIZEDLGPARAMS DlgParams ;  
      ColorDlg.SetBitmap (pBitmap);  
 
      memset ( &DlgParams, 0, sizeof ( SOLARIZEDLGPARAMS ) ) ;  
 
      DlgParams.uStructSize           = sizeof ( SOLARIZEDLGPARAMS ) ;  
      DlgParams.uDlgFlags       = DLG_SOLARIZE_SHOW_CONTEXTHELP;  
 
      ColorDlg.EnableCallBack (FALSE);  
      ColorDlg.EnablePreview (TRUE);  
      ColorDlg.EnableAutoProcess (TRUE);  
      ColorDlg.EnableToolbar (TRUE);  
      nRet = ColorDlg.SetSolarizeParams (&DlgParams) ;  
      if(nRet != SUCCESS) 
         return nRet; 
 
      nRet = ColorDlg.DoModalSolarize (hWnd);  
      if(nRet < 1) 
         return nRet; 
       pBitmap->SetHandle(ColorDlg.GetBitmap()->GetHandle ()); 
   } 
 
   if(LDialogColor::SetFont( NULL ) == NULL) 
      return FAILURE; 
 
   DeleteObject ( hMyFont ) ; 
 
   ReleaseDC (hWnd, m_pDC ) ; 
 
   return SUCCESS; 
} 
Help Version 20.0.2019.3.11
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2019 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Common Dialog C++ Class Library Help