【VC开源代码栏目提醒】:以下是网学会员为您推荐的VC开源代码-FontName.cpp,希望本篇文章对您学习有所帮助。
// FontName.cpp : implementation file
//
#include "stdafx.h"
#include "MyRichEdit.h"
#include "FontName.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFontName
CFontName::CFontName()
{
}
CFontName::~CFontName()
{
}
BEGIN_MESSAGE_MAP(CFontName, CComboBox)
//{{AFX_MSG_MAP(CFontName)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFontName message handlers
//回调函数
int CALLBACK CFontName::numEnumFontNameProc(LOGFONT *plf, TEXTMETRIC* lpntme, int FontType, LPARAM lParam)
{
//将字体添加到字体下拉框中
CFontName * fcb = (CFontName *) lParam;
fcb->AddString(plf->lfFaceName);
return 1;
}
void CFontName::AddFont(CDC *pDC)
{
//清空下拉菜单内容
Clear();
if (!pDC)
{
pDC = GetDC();
}
LOGFONT lf;
lf.lfFaceName[0] = 0;
lf.lfCharSet = DEFAULT_CHARSET;
//枚举系统字体
EnumFontFamilies(pDC->m_hDC, NULL, (FONTENUMPROC)numEnumFontNameProc, (LPARAM)this);
//如果字体数大于零,则将第一种字体作为默认显示字体
if(GetCount()>0)
SetCurSel(0);
}
上一篇:
FontDoc.cpp
下一篇:
科研管理杂志简介