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 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 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 ;
}
}
}
void TestFunction(LBitmap * pBitmap, HWND hWnd)
{
L_UINT uLen ;
HFONT hMyFont = NULL ;
L_TCHAR L_FAR* 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")) ;
CMyColorDlg::SetFont ( hMyFont ) ;
CMyColorDlg::GetStringLen ( DLG_SOLARIZE_IDSTR_CAPTION, &uLen ) ;
// sdd 1, for the terminating NULL
pszString = ( L_TCHAR L_FAR* ) GlobalAlloc ( GMEM_FIXED,
( uLen * sizeof ( L_TCHAR ) + 1 ) ) ;
CMyColorDlg::GetString( DLG_SOLARIZE_IDSTR_CAPTION, pszString ) ;
// display default caption string
MessageBox ( hWnd,pszString, TEXT("Default"), MB_OK ) ;
GlobalFree ( pszString ) ;
// change caption string
CMyColorDlg::SetString ( DLG_SOLARIZE_IDSTR_CAPTION, szNewCaption ) ;
// 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);
ColorDlg.SetSolarizeParams (&DlgParams) ;
ColorDlg.DoModalSolarize (hWnd);
pBitmap->SetHandle(ColorDlg.GetBitmap()->GetHandle());
}
LDialogColor::SetFont( NULL ) ;
DeleteObject ( hMyFont ) ;
ReleaseDC (hWnd, m_pDC ) ;
}