本文整理汇总了C++中ChooseFont函数的典型用法代码示例。如果您正苦于以下问题:C++ ChooseFont函数的具体用法?C++ ChooseFont怎么用?C++ ChooseFont使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ChooseFont函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PDC_choose_a_new_font
int PDC_choose_a_new_font( void)
{
LOGFONT lf = PDC_get_logical_font( 0);
CHOOSEFONT cf;
int rval;
extern HWND PDC_hWnd;
lf.lfHeight = -PDC_font_size;
debug_printf( "In PDC_choose_a_new_font: %d\n", lf.lfHeight);
memset( &cf, 0, sizeof( CHOOSEFONT));
cf.lStructSize = sizeof( CHOOSEFONT);
cf.Flags = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
cf.hwndOwner = PDC_hWnd;
cf.lpLogFont = &lf;
cf.rgbColors = RGB( 0, 0, 0);
rval = ChooseFont( &cf);
if( rval)
#ifdef PDC_WIDE
// should this be _tcscpy() ???
wcscpy( PDC_font_name, lf.lfFaceName);
#else
strcpy( PDC_font_name, lf.lfFaceName);
#endif
debug_printf( "rval %d; %ld\n", rval, CommDlgExtendedError( ));
debug_printf( "output size: %d\n", lf.lfHeight);
PDC_font_size = -lf.lfHeight;
return( rval);
}
示例2: ChooseMonoFont
/*
* ChooseMonoFont - allow the picking of a mono font
*/
bool ChooseMonoFont( HWND hwnd )
{
CHOOSEFONT cf;
LOGFONT lf;
HFONT font;
memset( &cf, 0, sizeof( CHOOSEFONT ) );
lf = logFont;
cf.lStructSize = sizeof( CHOOSEFONT );
cf.hwndOwner = hwnd;
cf.lpLogFont = &lf;
cf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT;
if( !variableAllowed ) {
cf.Flags |= CF_FIXEDPITCHONLY;
}
cf.nFontType = SCREEN_FONTTYPE;
cf.rgbColors = RGB( 0, 0, 0 );
if( !ChooseFont( &cf ) ) {
return( false );
}
font = CreateFontIndirect( &lf );
if( font == NULL ) {
return( false );
}
DeleteObject( fixedFont );
logFont = lf;
fixedFont = font;
return( true );
} /* ChooseMonoFont */
示例3: sizeof
void DesktopManager::ChoosePreviewWindowFont(HWND hDlg)
{
CHOOSEFONT cf;
cf.lStructSize = sizeof(CHOOSEFONT);
cf.hwndOwner = hDlg;
cf.hDC = (HDC)NULL;
cf.lpLogFont = &m_lfPreviewWindowFontInfo;
cf.iPointSize = 0;
cf.Flags = CF_SCREENFONTS | CF_EFFECTS | CF_FORCEFONTEXIST | CF_INITTOLOGFONTSTRUCT;
cf.rgbColors = m_crPreviewWindowFontColor;
cf.lCustData = 0;
cf.lpfnHook = (LPCFHOOKPROC)NULL;
cf.lpTemplateName = (LPTSTR)NULL;
cf.hInstance = (HINSTANCE)vdWindow;
cf.lpszStyle = (LPTSTR)NULL;
cf.nFontType = SCREEN_FONTTYPE;
cf.nSizeMin = 0;
cf.nSizeMax = 0;
if (ChooseFont(&cf))
{
if (m_hPreviewWindowFont)
DeleteObject(m_hPreviewWindowFont);
m_hPreviewWindowFont = CreateFontIndirect(cf.lpLogFont);
m_crPreviewWindowFontColor = cf.rgbColors;
vdWindow.Refresh();
}
}
示例4: selectFont
int selectFont(HWND hDlg, LOGFONT *lf)
{
COLORREF color=RGB(0, 0, 0);
logmsg("SelectFont");
HDC hDC = GetDC(hDlg);
CHOOSEFONT cf;
ZeroMemory(&cf, sizeof(CHOOSEFONT));
cf.lStructSize = sizeof(cf);
cf.hwndOwner = hDlg;
cf.hDC = hDC;
cf.lpLogFont = lf;
cf.rgbColors = 0;
cf.Flags = CF_INITTOLOGFONTSTRUCT | CF_EFFECTS | CF_BOTH | CF_FORCEFONTEXIST;
cf.nFontType = 0;
cf.rgbColors=color;
if (!ChooseFont(&cf)) {
if (cf.hDC)
DeleteDC(cf.hDC);
ReleaseDC(hDlg, hDC);
return 1;
}
if (cf.hDC)
DeleteDC(cf.hDC);
ReleaseDC(hDlg, hDC);
return 0;
}
示例5: CallChangeFont
/*------------------------------------------------------------------------
Procedure: CallChangeFont ID:1
Purpose: Calls the standard windows font change dialog. If the
user validates a font, it will destroy the current
font, and recreate a new font with the given
parameters.
Input: The calling window handle
Output: Zero if the user cancelled, 1 otherwise.
Errors: None
------------------------------------------------------------------------*/
static int CallChangeFont(HWND hwnd)
{
LOGFONT lf;
CHOOSEFONT cf;
int r;
HWND hwndChild;
memset(&cf, 0, sizeof(CHOOSEFONT));
memcpy(&lf, &CurrentFont, sizeof(LOGFONT));
cf.lStructSize = sizeof(CHOOSEFONT);
cf.hwndOwner = hwnd;
cf.lpLogFont = &lf;
cf.Flags = CF_SCREENFONTS | CF_EFFECTS | CF_APPLY | CF_INITTOLOGFONTSTRUCT;
cf.nFontType = SCREEN_FONTTYPE;
r = ChooseFont(&cf);
if (!r)
return (0);
DeleteObject(ProgramParams.hFont);
memcpy(&CurrentFont, &lf, sizeof(LOGFONT));
ProgramParams.hFont = CreateFontIndirect(&CurrentFont);
strcpy(CurrentFontName, CurrentFont.lfFaceName);
CurrentFontFamily = lf.lfPitchAndFamily;
CurrentFontStyle = lf.lfWeight;
hwndChild = (HWND) GetWindowLongPtr(hwndSession, DWLP_USER);
SendMessage(hwndChild,WM_SETFONT,(WPARAM)ProgramParams.hFont,0);
ForceRepaint();
return (1);
}
示例6: sizeof
void CTextInputCtrl::SetFont(HWND hwndParent)
{
CHOOSEFONT cf;
LOGFONT lf = _lfCurrentFont;
cf.lStructSize = sizeof(CHOOSEFONT);
cf.hwndOwner = hwndParent;
cf.lpLogFont = &lf;
cf.Flags = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
cf.rgbColors = RGB(0, 0, 0);
cf.lCustData = 0;
cf.lpfnHook = NULL;
cf.lpTemplateName = NULL;
cf.hInstance = NULL;
cf.lpszStyle = NULL;
cf.nFontType = SCREEN_FONTTYPE;
cf.nSizeMin = 0;
cf.nSizeMax = 0;
if (ChooseFont(&cf))
{
_lfCurrentFont = lf;
// Level 2 Support
SetCompositionFont();
InvalidateRect(_hwnd, NULL, TRUE);
}
}
示例7: OpenFontDialog
void OpenFontDialog(HWND hWnd)
{
HDC hDC = GetDC(hWnd);
CHOOSEFONT chf;
LOGFONT lf;
HFONT hFontNormal = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
GetObject(hFontNormal, sizeof(lf), &lf);
chf.hDC = CreateCompatibleDC(hDC);
ReleaseDC(hLeftWindow, hDC);
chf.lStructSize = sizeof (CHOOSEFONT);
chf.hwndOwner = hWnd;
chf.lpLogFont = &lf;
chf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT | CF_LIMITSIZE;
chf.rgbColors = RGB (0, 0, 0);
chf.lCustData = 0;
chf.hInstance = hInst;
chf.lpszStyle = (LPTSTR)NULL;
chf.nFontType = SCREEN_FONTTYPE;
chf.nSizeMin = 0;
chf.nSizeMax = 20;
chf.lpfnHook = (LPCFHOOKPROC)(FARPROC)NULL;
if (ChooseFont(&chf))
{
HFONT hFont = CreateFontIndirect(&lf);
SendMessage(hWnd, WM_SETFONT, (WPARAM) hFont, 0);
}
}
示例8: cmFonts
//*************************************************************************
// cmFonts -- use the Choose Fonts common dialog to get a new font spec
// from the user. To do this, we fill out a CHOOSEFONTS structure and
// pass it to the ChooseFonts routine. Windows 3.1 takes care of the rest!
//*************************************************************************
void cmFonts(HWND hWnd)
{
CHOOSEFONT CF;
LOGFONT FontRec = MainFontRec;
CF.lStructSize = sizeof(CF);
CF.hwndOwner = hWnd;
CF.Flags = CF_ANSIONLY | CF_TTONLY | CF_SCREENFONTS |
CF_INITTOLOGFONTSTRUCT | CF_ENABLETEMPLATE;
CF.nFontType = SCREEN_FONTTYPE;
CF.lpLogFont = &FontRec;
CF.nSizeMin = 20;
CF.nSizeMax = 20;
CF.lpTemplateName = "FontDlg";
CF.hInstance = hInst;
if (ChooseFont(&CF))
{
// Only get the font name, weight, and italics;
// we don't care about size
strcpy(MainFontRec.lfFaceName, FontRec.lfFaceName);
MainFontRec.lfWeight = FontRec.lfWeight;
MainFontRec.lfItalic = FontRec.lfItalic;
InvalidateRect(hwnd, NULL, TRUE);
}
} // end of cmFonts()
示例9: DlgChooseFont
int DlgChooseFont(HWND hwnd, char *fontName, int *fontHeight, int *fontWidth)
{
LOGFONT lf;
CHOOSEFONT cf;
memset(&lf,0,sizeof(LOGFONT));
if(fontHeight!=NULL) lf.lfHeight = *fontHeight;
if(fontWidth!=NULL) lf.lfWidth = *fontWidth;
if(fontName!=NULL) strcpy(lf.lfFaceName,fontName);
memset(&cf,0,sizeof(CHOOSEFONT));
cf.lStructSize = sizeof(CHOOSEFONT);
cf.hwndOwner = hwnd;
// cf.hDC = NULL;
cf.lpLogFont = &lf;
// cf.iPointSize = 16;
// cf.Flags = CF_ANSIONLY | CF_FORCEFONTEXIST ;
cf.Flags = CF_ANSIONLY | CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT;
// cf.rgbColors = RGB(0,0,0);
// cf.lCustData = NULL;
// cf.lpfnHook = NULL;
// cf.lpTemplateName = NULL;
// cf.hInstance = 0;
// cf.lpszStyle = NULL;
cf.nFontType = SCREEN_FONTTYPE;
// cf.nSizeMin = 4;
// cf.nSizeMax = 72;
if(ChooseFont(&cf)!=TRUE)
return -1;
if(fontName!=NULL) strcpy(fontName,lf.lfFaceName);
if(fontHeight!=NULL) *fontHeight = abs(lf.lfHeight);
if(fontWidth!=NULL) *fontWidth = lf.lfWidth;
return 0;
}
示例10: MyCreateFont
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_FIXEDPITCHONLY;
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);
}
示例11: memset
HFONT ringFont::Select(HWND hWnd/*=NULL*/)
{
CHOOSEFONT CF;
memset(&CF,0,sizeof(CHOOSEFONT));
//LOGFONT FontRec = m_lpMainFontRec;
CF.lStructSize = sizeof(CF);
CF.hwndOwner = hWnd;
CF.Flags = CF_ANSIONLY | CF_TTONLY | CF_SCREENFONTS |
CF_EFFECTS | CF_INITTOLOGFONTSTRUCT;// | CF_ENABLETEMPLATE;
CF.nFontType = SCREEN_FONTTYPE;
CF.lpLogFont = &m_lpMainFontRec;
CF.nSizeMin = 20;
CF.nSizeMax = 20;
CF.rgbColors = m_crColor;
//CF.lpTemplateName = "FontDlg";
CF.hInstance = GetInstance();
if (ChooseFont(&CF))
{
m_crColor = CF.rgbColors;
if(m_font && !m_bExtern)
DeleteObject(m_font);
m_font = CreateFontIndirect(&m_lpMainFontRec);
m_bExtern = FALSE;
}
return m_font;
}
示例12: changeFont
void changeFont(HWND hwnd)
{
CHOOSEFONT cf;
LOGFONT logfont;
GetObject(hfDefault, sizeof(LOGFONT), &logfont);
ZeroMemory(&cf, sizeof(cf));
cf.lStructSize = sizeof(CHOOSEFONT);
cf.Flags = CF_EFFECTS | CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
cf.hwndOwner = hwnd;
cf.lpLogFont = &logfont;
cf.rgbColors = textColour;
if(ChooseFont(&cf)) {
HFONT hfont = CreateFontIndirect(&logfont);
textColour = cf.rgbColors;
SendMessage(hEdit, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0));
DeleteObject(hfDefault);
if(hfont) {
hfDefault = hfont;
} else {
MessageBox(hwnd, "Failed to create font.", "Error", MB_OK | MB_ICONEXCLAMATION);
}
}
}
示例13: sizeof
void OnScreenDisplayWnd::SelectFont()
{
CHOOSEFONT cf;
cf.lStructSize = sizeof(CHOOSEFONT);
cf.hwndOwner = vdWindow;
cf.hDC = (HDC)NULL;
cf.lpLogFont = &m_lf;
cf.iPointSize = 0;
cf.Flags = CF_SCREENFONTS | CF_EFFECTS | CF_FORCEFONTEXIST | CF_INITTOLOGFONTSTRUCT;
cf.rgbColors = m_fgColor;
cf.lCustData = 0;
cf.lpfnHook = (LPCFHOOKPROC)NULL;
cf.lpTemplateName = (LPSTR)NULL;
cf.hInstance = (HINSTANCE)vdWindow;
cf.lpszStyle = (LPSTR)NULL;
cf.nFontType = SCREEN_FONTTYPE;
cf.nSizeMin = 0;
cf.nSizeMax = 0;
if (ChooseFont(&cf))
{
if (m_font)
DeleteObject(m_font);
m_font = CreateFontIndirect(cf.lpLogFont);
m_fgColor = cf.rgbColors;
}
}
示例14: DisplayWindow_GetFont
void CDisplayColoursDialog::OnChooseFont()
{
HFONT hFont;
DisplayWindow_GetFont(m_hPreviewDisplayWindow,reinterpret_cast<WPARAM>(&hFont));
LOGFONT lf;
GetObject(hFont,sizeof(lf),reinterpret_cast<LPVOID>(&lf));
CHOOSEFONT cf;
TCHAR szStyle[512];
cf.lStructSize = sizeof(cf);
cf.hwndOwner = m_hDlg;
cf.Flags = CF_FORCEFONTEXIST|CF_SCREENFONTS|CF_EFFECTS|CF_INITTOLOGFONTSTRUCT;
cf.lpLogFont = &lf;
cf.rgbColors = DisplayWindow_GetTextColor(m_hPreviewDisplayWindow);
cf.lCustData = NULL;
cf.lpszStyle = szStyle;
BOOL res = ChooseFont(&cf);
if(res)
{
/* TODO: This font must be freed. */
m_hDisplayFont = CreateFontIndirect(cf.lpLogFont);
m_TextColor = cf.rgbColors;
DisplayWindow_SetFont(m_hPreviewDisplayWindow,reinterpret_cast<WPARAM>(m_hDisplayFont));
DisplayWindow_SetTextColor(m_hPreviewDisplayWindow,m_TextColor);
}
}
示例15: win32_font_selector
void win32_font_selector (char *fontname, int flag)
{
CHOOSEFONT cf; /* info for font selection dialog */
ZeroMemory(&cf, sizeof cf);
cf.lStructSize = sizeof cf;
cf.Flags = CF_SCREENFONTS | CF_TTONLY | CF_LIMITSIZE |
CF_INITTOLOGFONTSTRUCT | CF_NOSCRIPTSEL;
if (flag == FIXED_FONT_SELECTION) {
cf.Flags |= CF_FIXEDPITCHONLY;
}
cf.nSizeMin = 6;
cf.nSizeMax = 24;
fontspec_to_win32(&cf, fontname, flag);
if (ChooseFont(&cf)) {
winfont_to_fontspec(fontname, &cf);
} else {
/* signal cancellation */
*fontname = '\0';
}
/* allocated via pango */
g_free(cf.lpLogFont);
}