void CCustomPropSheet::BuildPropPageArray(void)
{
	CDialogTemplate dlgtPageRes;

	__super::BuildPropPageArray();

	// get first page
	CPropertyPage* pPage = GetPage(0);
	ASSERT(pPage != NULL);

	// load the dialog template
	VERIFY(dlgtPageRes.Load(pPage->m_psp.pszTemplate));

	// get the font information

	// defaults
	CString strFaceName(_T("MS Shell Dlg 2"));
	WORD wPointSize = 8;

	if (!GetFontMetrics(strFaceName, wPointSize))
	{
		// obtain from resource template
		VERIFY(dlgtPageRes.GetFont(strFaceName, wPointSize));
	}

	if (m_fontPage.m_hObject != NULL)
	{
		VERIFY(m_fontPage.DeleteObject());
	}

	// create a font using the info from first page
	LOGFONT lf = { 0 };
	HDC hdcScreen = ::GetDC(NULL);
	ASSERT(hdcScreen != NULL);
	lf.lfHeight = ::MulDiv(-wPointSize, ::GetDeviceCaps(hdcScreen, LOGPIXELSY), 72);
	lf.lfWeight = FW_REGULAR;
	lf.lfCharSet = DEFAULT_CHARSET;
	lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
	lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
	lf.lfQuality = PROOF_QUALITY;
	lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
	_tcsncpy(lf.lfFaceName, strFaceName, LF_FACESIZE - 1);
	VERIFY(m_fontPage.CreateFontIndirect(&lf));
	::ReleaseDC(NULL, hdcScreen);
}
Exemple #2
0
IFontPtr SFontPool::GetFont(FONTSTYLE style,LPCTSTR pszFaceName)
{
    SStringT strFaceName(pszFaceName);
    if(strFaceName == m_lfDefault.lfFaceName) strFaceName = _T("");
    
    IFontPtr hftRet=0;
    FontKey key(style.dwStyle,strFaceName);
    if(HasKey(key))
    {
        hftRet=GetKeyObject(key);
    }
    else
    {
        if(strFaceName.IsEmpty()) strFaceName = m_lfDefault.lfFaceName;
        hftRet = _CreateFont(style,strFaceName);
        AddKeyObject(key,hftRet);
    }
    return hftRet;
}
void CSynBCGPEditView::ResetDefaultFont()
{
	HFONT hFont = (HFONT)::GetStockObject(DEFAULT_GUI_FONT);
	CDC* pDC = GetDC();

	CFont* pFont = pDC->SelectObject(CFont::FromHandle(hFont));
	pDC->SelectObject(pFont);
	::DeleteObject(hFont);

	LOGFONT lf;
	pFont->GetLogFont (&lf);

	CString strFontName(g_GlobalUtils.m_sStyleScheme.m_strEdtFontName);
	CopyMemory(lf.lfFaceName,(LPCTSTR)strFontName,(strFontName.GetLength() + 1) * sizeof(TCHAR));
	lf.lfWidth = 0;
	lf.lfEscapement = 0;
	lf.lfOrientation = 0;
	lf.lfWeight = g_GlobalUtils.m_sStyleScheme.m_bEdtFontBold ? FW_BOLD : FW_NORMAL;
	lf.lfItalic = g_GlobalUtils.m_sStyleScheme.m_bEdtFontItalic ? 1 : 0;
	lf.lfUnderline = 0;
	lf.lfStrikeOut = 0;
	lf.lfHeight = -MulDiv(g_GlobalUtils.m_sStyleScheme.m_uEdtFontSize, GetDeviceCaps(pDC->GetSafeHdc(), LOGPIXELSY), 72);
	lf.lfOutPrecision =	3;
	lf.lfClipPrecision = 2;
	lf.lfQuality = 1;
	lf.lfPitchAndFamily = 49;
	lf.lfCharSet = 0;

	LOGFONT glf;
	globalData.fontRegular.GetLogFont (&glf);
	CString strFaceName(glf.lfFaceName);
	if (0 == strFaceName.CompareNoCase(_T("΢ÈíÑźÚ")))
	{
		lf.lfQuality = 5;
	}

	m_Font.CreateFontIndirect(&lf);
	m_pEdit->SetFont (&m_Font);
}