예제 #1
0
파일: pdcdisp.c 프로젝트: rexx-org/PDCurses
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
0
/*
 * 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
0
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
0
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
0
파일: menu.c 프로젝트: retired-camels/ocaml
/*------------------------------------------------------------------------
 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);
}
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
0
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
0
//*************************************************************************
// 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
0
LONG PopFontChooseTabFont (HWND hwnd)
     {
	 BOOL res;
     CHOOSEFONT cf;

     cf.lStructSize      = sizeof (CHOOSEFONT) ;
     cf.hwndOwner        = hwnd ;
     cf.hDC              = NULL ;
     cf.lpLogFont        = &temptabfont ;
     cf.iPointSize       = 0 ;
     cf.Flags            = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS
												  | CF_EFFECTS;
     cf.rgbColors        = NULL ;
     cf.lCustData        = 0L ;
     cf.lpfnHook         = NULL ;
     cf.lpTemplateName   = NULL ;
     cf.hInstance        = NULL ;
     cf.lpszStyle        = NULL ;
     cf.nFontType        = 0 ;               // Returned from ChooseFont
     cf.nSizeMin         = 0 ;
     cf.nSizeMax         = 0 ;

     res=ChooseFont (&cf);
     return MAKELONG(res, cf.iPointSize);
     }
예제 #10
0
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;
}
예제 #11
0
파일: WinmorControl.c 프로젝트: g8bpq/BPQ32
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); 
} 
예제 #12
0
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;
}
예제 #13
0
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);
		}
	}
}
예제 #14
0
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;
   }
}
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);
	}
}
예제 #16
0
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); 
}
예제 #17
0
void
CSelectionView::AttachedToWindow()
{
	BView::AttachedToWindow();
	SetViewColor(kB_GrayTable[6]);
	fCellView->AttachSelectionView(this);
	ChooseFont();
} // AttachedToWindow
예제 #18
0
파일: main.cpp 프로젝트: zie87/sds
//
//	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);
}
예제 #19
0
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;
}
예제 #20
0
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;
}
예제 #21
0
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);
}
예제 #22
0
static bool userPickFont( LOGFONT *l, HWND parent )
{
    CHOOSEFONT  cf;

    memset( &cf, 0, sizeof( CHOOSEFONT ) );

    cf.lStructSize = sizeof( CHOOSEFONT );
    cf.hwndOwner = parent;
    cf.lpLogFont = l;
    cf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT;
    cf.rgbColors = RGB( 0, 0, 0 );
    cf.nFontType = SCREEN_FONTTYPE;

    return( ChooseFont( &cf ) );
}
예제 #23
0
/*-----------------------------------------------------------------------------
    Name        : dbwFontChoose
    Description : Chooses the current font using the ChooseFont dialog
    Inputs      : ..
    Outputs     : Set the dbwFontWidth and dbwFontHeight variables
    Return      : ERROR if user cancelled or cannot select a font
----------------------------------------------------------------------------*/
sdword dbwFontChoose(void)
{
    CHOOSEFONT chooseFont;

    chooseFont.lStructSize = sizeof(CHOOSEFONT);
    chooseFont.hwndOwner = hDebugWindow;
    chooseFont.hDC = NULL;                                  //only used for printer fonts
    chooseFont.lpLogFont = &dbwLogicalFont;
    chooseFont.Flags = CF_FIXEDPITCHONLY | CF_LIMITSIZE | CF_SCREENFONTS;
    chooseFont.nSizeMin = DBW_FontPointsMin;
    chooseFont.nSizeMax = DBW_FontPointsMax;

    if (ChooseFont(&chooseFont) != TRUE)                    //select the font
        return(ERROR);
    return(OKAY);
}
예제 #24
0
static void choose_font(void)
{
    CHOOSEFONT cf;

    memset(&cf, 0, sizeof(CHOOSEFONT));
    cf.lStructSize=sizeof(CHOOSEFONT);
    cf.hwndOwner=wndMain;
    cf.Flags=CF_FIXEDPITCHONLY|CF_NOSCRIPTSEL|CF_SCREENFONTS|CF_INITTOLOGFONTSTRUCT;
    cf.lpLogFont=&df;
    if (!ChooseFont(&cf))
        return;
    save_font();
    draw_free();
    draw_init(&df);
    InvalidateRect(termwnd, 0, 1);
}
예제 #25
0
void CMainFrame::OnSimulatorSetFont()
{
    CHOOSEFONT choiceFont;

    // Initialize the font structure:
    //
    memset(&choiceFont, 0, sizeof(choiceFont));
    choiceFont.lStructSize = sizeof(choiceFont);
    choiceFont.hwndOwner = g_pView->m_hWnd ;
    LOGFONT lFont;
    CFont* cFont = g_pView->GetSpimFont();
    cFont->GetLogFont(&lFont);
    choiceFont.lpLogFont = &lFont;
    choiceFont.Flags = CF_INITTOLOGFONTSTRUCT | CF_FIXEDPITCHONLY | CF_SCREENFONTS;

    if (ChooseFont(&choiceFont))
    {
        g_pView->SetSpimFont(choiceFont.lpLogFont);
    }
}
예제 #26
0
/*
	FUNCTION: ChooseFixedFont(HWND)

	PURPOSE: Changes the terminal font and appropriately resizes the window.

	PARAMETERS:
		hWnd		- window handle of menu owner

	NOTE: There is a bug whereby when you choose the same font but set it to
		  italic, it doesn't register the change.

*/
void ChooseFixedFont(HWND hWnd) {
	CHOOSEFONT	cf = {0};
	LOGFONT		lf;

	lf = LFSCREENFONT(TermInfo);

	cf.lStructSize	= sizeof(CHOOSEFONT);
	cf.hwndOwner	= hWnd;
	cf.lpLogFont	= &lf;
	cf.Flags		= CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_NOSCRIPTSEL;
	cf.rgbColors	= FGCOLOUR(TermInfo);
	
	if (!ChooseFont(&cf)) {
		// We'll do something I'm sure!
	}

	InitNewFont(lf, cf.rgbColors);

	ResizeTerm(hWnd);
}
예제 #27
0
파일: shell.cpp 프로젝트: beru/sakura
/*フォント選択ダイアログ
	@param plf [in,out]
	@param piPointSize [in,out] 1/10ポイント単位
	
	2008.04.27 kobake CEditDoc::SelectFont から分離
	2009.10.01 ryoji ポイントサイズ(1/10ポイント単位)引数追加
*/
BOOL MySelectFont( LOGFONT* plf, INT* piPointSize, HWND hwndDlgOwner, bool FixedFontOnly )
{
	// 2004.02.16 Moca CHOOSEFONTをメンバから外す
	CHOOSEFONT cf;
	/* CHOOSEFONTの初期化 */
	::ZeroMemory( &cf, sizeof( cf ) );
	cf.lStructSize = sizeof( cf );
	cf.hwndOwner = hwndDlgOwner;
	cf.hDC = NULL;
	cf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT;
	if( FixedFontOnly ){
		//FIXEDフォント
		cf.Flags |= CF_FIXEDPITCHONLY;
	}
	cf.lpLogFont = plf;
	if( !ChooseFont( &cf ) ){
#ifdef _DEBUG
		DWORD nErr;
		nErr = CommDlgExtendedError();
		switch( nErr ){
		case CDERR_FINDRESFAILURE:	MYTRACE( _T("CDERR_FINDRESFAILURE \n") );	break;
		case CDERR_INITIALIZATION:	MYTRACE( _T("CDERR_INITIALIZATION \n") );	break;
		case CDERR_LOCKRESFAILURE:	MYTRACE( _T("CDERR_LOCKRESFAILURE \n") );	break;
		case CDERR_LOADRESFAILURE:	MYTRACE( _T("CDERR_LOADRESFAILURE \n") );	break;
		case CDERR_LOADSTRFAILURE:	MYTRACE( _T("CDERR_LOADSTRFAILURE \n") );	break;
		case CDERR_MEMALLOCFAILURE:	MYTRACE( _T("CDERR_MEMALLOCFAILURE\n") );	break;
		case CDERR_MEMLOCKFAILURE:	MYTRACE( _T("CDERR_MEMLOCKFAILURE \n") );	break;
		case CDERR_NOHINSTANCE:		MYTRACE( _T("CDERR_NOHINSTANCE \n") );		break;
		case CDERR_NOHOOK:			MYTRACE( _T("CDERR_NOHOOK \n") );			break;
		case CDERR_NOTEMPLATE:		MYTRACE( _T("CDERR_NOTEMPLATE \n") );		break;
		case CDERR_STRUCTSIZE:		MYTRACE( _T("CDERR_STRUCTSIZE \n") );		break;
		case CFERR_MAXLESSTHANMIN:	MYTRACE( _T("CFERR_MAXLESSTHANMIN \n") );	break;
		case CFERR_NOFONTS:			MYTRACE( _T("CFERR_NOFONTS \n") );			break;
		}
#endif
		return FALSE;
	}
	*piPointSize = cf.iPointSize;

	return TRUE;
}
예제 #28
0
static void DoModScriptWindow(HWND wnd)
{
	SendMessage(wnd, EM_EXLIMITTEXT, 0, 0x00FFFFFF);

	bool	setFont = false;

	if(GetAsyncKeyState(VK_F11))
	{
		LOGFONT		newFontInfo = fontInfo;
		CHOOSEFONT	chooseInfo = { sizeof(chooseInfo) };
		
		chooseInfo.lpLogFont = &newFontInfo;
		chooseInfo.Flags = CF_INITTOLOGFONTSTRUCT | CF_NOVERTFONTS | CF_SCREENFONTS;

		if(ChooseFont(&chooseInfo))
		{
			HANDLE	newFont = CreateFontIndirect(&newFontInfo);
			if(newFont)
			{
				DeleteObject(fontHandle);

				fontInfo = newFontInfo;
				fontHandle = newFont;
			}
			else
				_WARNING("couldn't create font");
		}

		setFont = true;
	}

	if(GetAsyncKeyState(VK_F12) || setFont || userSetFont)
	{
		userSetFont = true;
		SendMessage(wnd, EM_SETTEXTMODE, TM_PLAINTEXT, 0);
		SendMessage(wnd, WM_SETFONT, (WPARAM)fontHandle, 1);

		UInt32	tabStopSize = 16;
		SendMessage(wnd, EM_SETTABSTOPS, 1, (LPARAM)&tabStopSize);	// one tab stop every 16 dialog units
	}
}
예제 #29
0
BOOL ChooseFontDLG (HWND hWnd,LOGFONT &lf)
{
	CHOOSEFONT cf ;
	cf.lStructSize    = sizeof (CHOOSEFONT) ;
	cf.hwndOwner      = hWnd ;
	cf.hDC            = NULL ;
	cf.lpLogFont      = &lf ;
	cf.iPointSize     = 0 ;
	cf.Flags          = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
	cf.rgbColors      = 0;
	cf.lCustData      = 0 ;
	cf.lpfnHook       = NULL ;
	cf.lpTemplateName = NULL ;
	cf.hInstance      = NULL ;
	cf.lpszStyle      = NULL ;
	cf.nFontType      = 0 ;               // Returned from ChooseFont
	cf.nSizeMin       = 0 ;
	cf.nSizeMax       = 0 ;

	return (BOOL)ChooseFont (&cf) ; 
}
예제 #30
0
// ****************************************************************************
// DlgChooseFont
// hwnd: Owner Window of This Dialog
// hwndFontChange: Window to Change Font
// hFontPre: Previous Font of hwndFontChange (Call CloseHandle())
int DlgChooseFontAndApply(HWND hwnd, HWND hwndFontChange, HFONT hFontPre, char *fontname, int *fontheight, int *fontwidth)
{
	LOGFONT lf;
	CHOOSEFONT cf;
	HFONT hFont;
	memset(&lf,0,sizeof(LOGFONT));
	memset(&cf,0,sizeof(CHOOSEFONT));

//	lf.lfHeight = 16;
//	lf.lfWidth = 8;
	strcpy(lf.lfFaceName,"MS 明朝");
    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_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;
	ChooseFont(&cf);

//	if(ChooseFont(&cf)==TRUE)
//		return -1;
	if(hFontPre!=NULL)
		CloseHandle(hFontPre);
	hFont = CreateFontIndirect(&lf);
	SendMessage(hwndFontChange,WM_SETFONT,(WPARAM)hFont,(LPARAM)MAKELPARAM(TRUE,0));
	if(fontname!=NULL) strcpy(fontname,lf.lfFaceName);
	if(fontheight!=NULL) *fontheight = lf.lfHeight;
	if(fontwidth!=NULL) *fontwidth = lf.lfWidth;
	return 0;
}