• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ChooseFont函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ChooseFont函数的典型用法代码示例。如果您正苦于以下问题:C++ ChooseFont函数的具体用法?C++ ChooseFont怎么用?C++ ChooseFont使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ChooseFont函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:rexx-org,项目名称:PDCurses,代码行数:28,代码来源:pdcdisp.c


示例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 */
开发者ID:Azarien,项目名称:open-watcom-v2,代码行数:35,代码来源:font.c


示例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();
   }
}
开发者ID:HaijinW,项目名称:VirtualDimension,代码行数:31,代码来源:DesktopManager.cpp


示例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;
}
开发者ID:0xmono,项目名称:miranda-ng,代码行数:33,代码来源:options.cpp


示例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);
}
开发者ID:retired-camels,项目名称:ocaml,代码行数:38,代码来源:menu.c


示例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);
    }

}
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:30,代码来源:TextInputCtrl.cpp


示例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);
	}
}
开发者ID:weimingtom,项目名称:twentylight,代码行数:27,代码来源:twentylight.cpp


示例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()
开发者ID:LucasvBerkel,项目名称:TweedejaarsProject,代码行数:31,代码来源:TRUETYPE.C


示例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;
}
开发者ID:Distrotech,项目名称:TiMidity,代码行数:35,代码来源:w32g_ut2.c


示例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); 
} 
开发者ID:g8bpq,项目名称:BPQ32,代码行数:35,代码来源:WinmorControl.c


示例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;
}
开发者ID:tianjigezhu,项目名称:UI-Library,代码行数:28,代码来源:ringfont.cpp


示例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);
		}
	}
}
开发者ID:REPOmAN2v2,项目名称:SimpleEditor,代码行数:28,代码来源:editor.c


示例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;
   }
}
开发者ID:Mrunali,项目名称:Virtual-Dimention,代码行数:29,代码来源:OnScreenDisplay.cpp


示例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);
	}
}
开发者ID:3scp8,项目名称:explorerplusplus,代码行数:29,代码来源:DisplayColoursDialog.cpp


示例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); 
}
开发者ID:HelioGuilherme66,项目名称:gretl,代码行数:26,代码来源:gretlwin32.c


示例16: SetViewColor

void
CSelectionView::AttachedToWindow()
{
	BView::AttachedToWindow();
	SetViewColor(kB_GrayTable[6]);
	fCellView->AttachSelectionView(this);
	ChooseFont();
} // AttachedToWindow
开发者ID:ModeenF,项目名称:OpenSumIt,代码行数:8,代码来源:SelectionView.cpp


示例17: GetFont

//
//	Display the font-chooser dialog
//
BOOL GetFont(HWND hwndParent, LOGFONT *logfont)
{
	CHOOSEFONT cf = { sizeof(cf) };

	cf.hwndOwner = hwndParent;
	cf.lpLogFont = logfont;
	cf.Flags	 = CF_SCREENFONTS|CF_FORCEFONTEXIST|CF_INITTOLOGFONTSTRUCT;

	return ChooseFont(&cf);
}
开发者ID:zie87,项目名称:sds,代码行数:13,代码来源:main.cpp


示例18: scaleresource_choosefont

int scaleresource_choosefont (HWND hDlg, int fonttype)
{
	CHOOSEFONT cf = { 0 };
	LOGFONT lf = { 0 };
	HDC hdc;
	TCHAR *fontname[2];
	int *fontsize[2], *fontstyle[2], *fontweight[2];
	int lm;

	fontname[0] = fontname_gui;
	fontname[1] = fontname_list;
	fontsize[0] = &fontsize_gui;
	fontsize[1] = &fontsize_list;
	fontstyle[0] = &fontstyle_gui;
	fontstyle[1] = &fontstyle_list;
	fontweight[0] = &fontweight_gui;
	fontweight[1] = &fontweight_list;

	cf.lStructSize = sizeof cf;
	cf.hwndOwner = hDlg;
	cf.Flags = CF_FORCEFONTEXIST | CF_INITTOLOGFONTSTRUCT | CF_NOSCRIPTSEL | CF_SCREENFONTS;
	cf.lpLogFont = &lf;
	cf.nFontType = REGULAR_FONTTYPE;
	cf.iPointSize = *fontsize[fonttype];

	hdc = GetDC (NULL);
	lm = GetDeviceCaps (hdc, LOGPIXELSY);

	_tcscpy (lf.lfFaceName, fontname[fonttype]);
	lf.lfHeight = -MulDiv (*fontsize[fonttype], lm, 72);
	lf.lfWeight = *fontweight[fonttype];
	lf.lfItalic = (*fontstyle[fonttype] & ITALIC_FONTTYPE) != 0;

	if (!ChooseFont (&cf)) {
		ReleaseDC (NULL, hdc);
		return 0;
	}

	_tcscpy (fontname[fonttype], lf.lfFaceName);
	*fontsize[fonttype] = lf.lfHeight;
	*fontsize[fonttype] = -MulDiv (*fontsize[fonttype], 72, GetDeviceCaps (hdc, LOGPIXELSY));

	*fontstyle[fonttype] = lf.lfItalic ? ITALIC_FONTTYPE : 0;

	*fontweight[fonttype] = lf.lfWeight;

	ReleaseDC (NULL, hdc);

	regsetfont (NULL, fontprefix, fontreg[fonttype], fontname[fonttype], *fontsize[fonttype], *fontstyle[fonttype], *fontweight[fonttype]);

	openfont (true);


	return 1;
}
开发者ID:Blonder,项目名称:WinUAE,代码行数:55,代码来源:win32gui_extra.cpp


示例19: OnChooseFont

HRESULT OnChooseFont(HWND hwnd)
{
    HRESULT hr = S_OK;

    LOGFONT logFont = g_logFont;

    CHOOSEFONT font  = { 0 };
    font.lStructSize = sizeof(font);
    font.hwndOwner   = hwnd;
    font.lpLogFont   = &logFont;
    font.iPointSize  = static_cast<int>(g_fontSize * (720 / 96.0f));

    // Don't show vertical fonts because we don't do vertical layout and don't show
    // bitmap fonts because DirectWrite doesn't support them.
    font.Flags = CF_SCREENFONTS | CF_SCALABLEONLY | CF_NOVERTFONTS | CF_INITTOLOGFONTSTRUCT;

    // Show the common font dialog box.
    if (ChooseFont(&font))
    {
        // The lfFaceName might not be initialized if the user didn't select a face name.
        if (logFont.lfFaceName[0] == L'\0')
            memcpy(logFont.lfFaceName, g_logFont.lfFaceName, sizeof(logFont.lfFaceName));

        float newFontSize = font.iPointSize * (96.0f / 720);

        // Map the Win32 font properties to an IDWriteTextFormat.
        IDWriteTextFormat* newTextFormat = NULL;
        HRESULT hr = CreateTextFormatFromLOGFONT(logFont, newFontSize, &newTextFormat);

        if (SUCCEEDED(hr))
        {
            // Save the new font properties.
            g_logFont = logFont;
            g_fontSize = newFontSize;
            SafeAttach(&g_textFormat, SafeDetach(&newTextFormat));

            if (g_renderer != NULL)
            {
                g_renderer->SetFormat(g_textFormat);
            }

            InvalidateRect(hwnd, NULL, TRUE);
        }

        SafeRelease(&newTextFormat);
    }

    // Potentially expected error, but not fatal,
    // so just do nothing.
    if (hr == DWRITE_E_NOFONT)
        hr = S_OK;

    return hr;
}
开发者ID:AbdoSalem95,项目名称:WindowsSDK7-Samples,代码行数:54,代码来源:RenderTest.cpp


示例20: ZeroMemory

bool ConfigPage::DoFontChooser(HWND hwndDlg)
{
  CHOOSEFONT chooseFont;

  ZeroMemory(&chooseFont, sizeof(CHOOSEFONT));
  chooseFont.lStructSize = sizeof(CHOOSEFONT);
  chooseFont.hwndOwner = hwndDlg;
  chooseFont.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT | CF_NOSCRIPTSEL;
  chooseFont.lpLogFont = &newFont;

  return (ChooseFont(&chooseFont) == TRUE);
}
开发者ID:Alim-Oezdemir,项目名称:emergedesktop,代码行数:12,代码来源:ConfigPage.cpp



注:本文中的ChooseFont函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ChoosePixelFormat函数代码示例发布时间:2022-05-30
下一篇:
C++ ChooseColor函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap