Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
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: |
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"); 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(CMyColorDlg::SetFont ( hMyFont ) == NULL) return FAILURE; nRet = CMyColorDlg::GetStringLen ( DLG_SOLARIZE_IDSTR_CAPTION, &uLen ) ; if(nRet != SUCCESS) return nRet; // sdd 1, for the terminating NULL pszString = ( L_TCHAR * ) GlobalAlloc ( GMEM_FIXED, ( uLen * sizeof ( L_TCHAR ) + 1 ) ) ; nRet = CMyColorDlg::GetString( DLG_SOLARIZE_IDSTR_CAPTION, pszString, uLen) ; if(nRet != SUCCESS) return nRet; // display default caption string MessageBox ( hWnd,pszString, TEXT("Default"), MB_OK ) ; GlobalFree ( pszString ) ; // change caption string nRet = CMyColorDlg::SetString ( DLG_SOLARIZE_IDSTR_CAPTION, szNewCaption ) ; if(nRet != SUCCESS) return nRet; // now, display the dialog to see our changes { CMyColorDlg ColorDlg; 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; }